SlideShare a Scribd company logo
1 of 16
Download to read offline
AngularJS
Basic Building Blocks
Prepared by
Manaday Mavani
April, 2016
It is
● Frontend JavaScript MVC framework
● 100% JavaScript
● 100% client-side
It is not
● JS Library
● DOM Manipulation Library like jQuery
● Just another templating system
It helps in
● Single Page Applications
● Logical separation (MVC)
● Two way data binding
● Reusable components
● Templating
● Filters
● Form validations
Basic Building Blocks
● Directives - Abstract instruction on HTML
● Modules - Collection
● Expressions - Templating mechanism to bind dynamic content
● Controllers - Business logic stuff
● $scope - Glue between View and Controller
● Services - Encapsulate related responsibilities
● Filters - Transform data
● Dependency Injection - Delegate responsibility to the injector
Primary Directives
● ng-app
● ng-controller
● ng-model
● ng-repeat
● ng-include
● ng-change
● ng-class
● ng-show
● ng-hide
● ng-if
● ng-view
● ng-switch
● ng-click
ng-app
● Provides auto-bootstrap
● Specify AngularJS module to be used as root module for the application
● Typically placed near root element
○ <html ng-app=”app-name”> OR <body ng-app=”app-name”>
● Can not be nested within another ng-app
● Example - http://plnkr.co/edit/0YNo7LZtkVJnY2iDl4QO?p=preview
ng-controller
● Attaches a controller class to the view
● Declaration styles
○ as syntax: ng-controller=”SettingsController as settings”
○ $scope way: ng-controller=”SettingsController”
● Example: http://plnkr.co/edit/SPtMXwVPifnK2qGD0Bsf?p=preview
ng-model
● Used for 2-way bindings for form elements like input, select, textarea
● <input type=”text” ng-model=”scope-prop” />
● Example: http://plnkr.co/edit/Pf04Gkw8xaSZIPBQbNPg?p=preview
ng-click
● Allows to specify custom behavior when clicked
● <button ng-click=”count = count + 1”>Increment</button>
● Example: http://plnkr.co/edit/l7LavHKpeXA2RQc47UDb?p=preview
ng-include
● Fetches, compiles and includes an external HTML fragment
● Helps to abstract away the details
● <ng-include src="'PartialTemplate.html'" onload="expression"></ng-include>
● Example: http://plnkr.co/edit/A9Sj6pIDk4TDJytzwXth?p=preview
ng-class
● To dynamically set CSS classes on HTML element by data binding expression
● ng-class operates in 3 different ways
○ If expression is string, it should be one or more space-delimited class names
○ If expression is object, it should like key-value pair where key represents class name
○ If expression is array, each element should either be a string or an object
● Examples:
○ Basic: http://plnkr.co/edit/A9Sj6pIDk4TDJytzwXth?p=preview
○ Advanced: http://plnkr.co/edit/67YGWFFN7h7SBTPXUREC?p=info
Let’s Build: Github Viewer App
● Pages: Search, Repositories, Contributors
● You will learn
○ Basic app structure
○ Controllers implementation
○ Services to fetch data from API Endpoints
○ Routing
○ Sorting
● Source code on Github - https://github.com/ManadayM/ngGithubViewer
Resources
● Shaping up with AngularJS by Codeschool
● AngularJS Fundamentals By Egghead.io
● A Better Way to Learn AngularJS by Thinkster
● AngularJS Blog Series by LosTechies
● AngularJS Masterclass on Udemy (Paid)
● Controller As Syntax
● $scope vs this
● Custom Directives
● AngularJS Styleguide by Johnpapa
● Promises by HTML5Rocks, Promises explained by Toptal
Thanks!

More Related Content

What's hot

Web topic 21 pass info via javascript
Web topic 21  pass info via javascriptWeb topic 21  pass info via javascript
Web topic 21 pass info via javascript
CK Yang
 

What's hot (10)

Web topic 21 pass info via javascript
Web topic 21  pass info via javascriptWeb topic 21  pass info via javascript
Web topic 21 pass info via javascript
 
Javascript DOM
Javascript DOMJavascript DOM
Javascript DOM
 
Live Project On ASP.Net Core 2.0 MVC - Free Webinar
Live Project On ASP.Net Core 2.0 MVC - Free WebinarLive Project On ASP.Net Core 2.0 MVC - Free Webinar
Live Project On ASP.Net Core 2.0 MVC - Free Webinar
 
Grails gotchas and best practices
Grails gotchas and best practicesGrails gotchas and best practices
Grails gotchas and best practices
 
Performance & dev tools
Performance & dev toolsPerformance & dev tools
Performance & dev tools
 
JavaScript with Syntax & Implementation
JavaScript with Syntax & ImplementationJavaScript with Syntax & Implementation
JavaScript with Syntax & Implementation
 
Chrome DevTools Basics
Chrome DevTools BasicsChrome DevTools Basics
Chrome DevTools Basics
 
What is HTML
What is HTMLWhat is HTML
What is HTML
 
The angular way 19 october 2013 Gdańsk
The angular way   19 october 2013 GdańskThe angular way   19 october 2013 Gdańsk
The angular way 19 october 2013 Gdańsk
 
Concept of flexible open api server with node.js
Concept of  flexible open api server with node.jsConcept of  flexible open api server with node.js
Concept of flexible open api server with node.js
 

Viewers also liked (11)

Front-end tools
Front-end toolsFront-end tools
Front-end tools
 
After Effects for blog
After Effects for blogAfter Effects for blog
After Effects for blog
 
Sound
SoundSound
Sound
 
Aco blog
Aco blogAco blog
Aco blog
 
Bilancio Expo Milano 2015
Bilancio Expo Milano 2015Bilancio Expo Milano 2015
Bilancio Expo Milano 2015
 
فهد الفضل cv-FR
فهد الفضل cv-FRفهد الفضل cv-FR
فهد الفضل cv-FR
 
Heppy
HeppyHeppy
Heppy
 
GulpGruntNPM
GulpGruntNPMGulpGruntNPM
GulpGruntNPM
 
NPM, Bower and Gulp Kickstart in Visual Studio
 NPM, Bower and Gulp Kickstart in Visual Studio NPM, Bower and Gulp Kickstart in Visual Studio
NPM, Bower and Gulp Kickstart in Visual Studio
 
Meetup#6: AWS-AI & Lambda Serverless
Meetup#6: AWS-AI & Lambda Serverless Meetup#6: AWS-AI & Lambda Serverless
Meetup#6: AWS-AI & Lambda Serverless
 
reveal.js 3.0.0
reveal.js 3.0.0reveal.js 3.0.0
reveal.js 3.0.0
 

Similar to AngularJS Basics

JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating FrameworksJSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
Mario Heiderich
 

Similar to AngularJS Basics (20)

AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in Components
 
Tango with django
Tango with djangoTango with django
Tango with django
 
Introduction to AngularJS By Bharat Makwana
Introduction to AngularJS By Bharat MakwanaIntroduction to AngularJS By Bharat Makwana
Introduction to AngularJS By Bharat Makwana
 
Nicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JSNicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JS
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
 
Dive into AngularJS and directives
Dive into AngularJS and directivesDive into AngularJS and directives
Dive into AngularJS and directives
 
GDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSGDayX - Advanced Angular.JS
GDayX - Advanced Angular.JS
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 
AngularJS
AngularJSAngularJS
AngularJS
 
Foster - Getting started with Angular
Foster - Getting started with AngularFoster - Getting started with Angular
Foster - Getting started with Angular
 
Angular.js presentation
Angular.js presentationAngular.js presentation
Angular.js presentation
 
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating FrameworksJSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
 
Drupal performance
Drupal performanceDrupal performance
Drupal performance
 
Angular js
Angular jsAngular js
Angular js
 
Angular.js for beginners
Angular.js for beginners Angular.js for beginners
Angular.js for beginners
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 

Recently uploaded (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 

AngularJS Basics

  • 1. AngularJS Basic Building Blocks Prepared by Manaday Mavani April, 2016
  • 2. It is ● Frontend JavaScript MVC framework ● 100% JavaScript ● 100% client-side
  • 3. It is not ● JS Library ● DOM Manipulation Library like jQuery ● Just another templating system
  • 4. It helps in ● Single Page Applications ● Logical separation (MVC) ● Two way data binding ● Reusable components ● Templating ● Filters ● Form validations
  • 5. Basic Building Blocks ● Directives - Abstract instruction on HTML ● Modules - Collection ● Expressions - Templating mechanism to bind dynamic content ● Controllers - Business logic stuff ● $scope - Glue between View and Controller ● Services - Encapsulate related responsibilities ● Filters - Transform data ● Dependency Injection - Delegate responsibility to the injector
  • 6. Primary Directives ● ng-app ● ng-controller ● ng-model ● ng-repeat ● ng-include ● ng-change ● ng-class ● ng-show ● ng-hide ● ng-if ● ng-view ● ng-switch ● ng-click
  • 7. ng-app ● Provides auto-bootstrap ● Specify AngularJS module to be used as root module for the application ● Typically placed near root element ○ <html ng-app=”app-name”> OR <body ng-app=”app-name”> ● Can not be nested within another ng-app ● Example - http://plnkr.co/edit/0YNo7LZtkVJnY2iDl4QO?p=preview
  • 8. ng-controller ● Attaches a controller class to the view ● Declaration styles ○ as syntax: ng-controller=”SettingsController as settings” ○ $scope way: ng-controller=”SettingsController” ● Example: http://plnkr.co/edit/SPtMXwVPifnK2qGD0Bsf?p=preview
  • 9. ng-model ● Used for 2-way bindings for form elements like input, select, textarea ● <input type=”text” ng-model=”scope-prop” /> ● Example: http://plnkr.co/edit/Pf04Gkw8xaSZIPBQbNPg?p=preview
  • 10. ng-click ● Allows to specify custom behavior when clicked ● <button ng-click=”count = count + 1”>Increment</button> ● Example: http://plnkr.co/edit/l7LavHKpeXA2RQc47UDb?p=preview
  • 11. ng-include ● Fetches, compiles and includes an external HTML fragment ● Helps to abstract away the details ● <ng-include src="'PartialTemplate.html'" onload="expression"></ng-include> ● Example: http://plnkr.co/edit/A9Sj6pIDk4TDJytzwXth?p=preview
  • 12. ng-class ● To dynamically set CSS classes on HTML element by data binding expression ● ng-class operates in 3 different ways ○ If expression is string, it should be one or more space-delimited class names ○ If expression is object, it should like key-value pair where key represents class name ○ If expression is array, each element should either be a string or an object ● Examples: ○ Basic: http://plnkr.co/edit/A9Sj6pIDk4TDJytzwXth?p=preview ○ Advanced: http://plnkr.co/edit/67YGWFFN7h7SBTPXUREC?p=info
  • 13. Let’s Build: Github Viewer App ● Pages: Search, Repositories, Contributors ● You will learn ○ Basic app structure ○ Controllers implementation ○ Services to fetch data from API Endpoints ○ Routing ○ Sorting ● Source code on Github - https://github.com/ManadayM/ngGithubViewer
  • 14. Resources ● Shaping up with AngularJS by Codeschool ● AngularJS Fundamentals By Egghead.io ● A Better Way to Learn AngularJS by Thinkster ● AngularJS Blog Series by LosTechies ● AngularJS Masterclass on Udemy (Paid) ● Controller As Syntax ● $scope vs this ● Custom Directives ● AngularJS Styleguide by Johnpapa ● Promises by HTML5Rocks, Promises explained by Toptal
  • 15.