SlideShare a Scribd company logo
1 of 18
UP AND RUNNING
WITH FRONT END
WEB
DEVELOPMENT
ANGULARJS
Requirements
oAngularJS has no dependencies on any other libraries or framework.
oAdd `ng-app` attribute in your HTML (angular directive, ng is a short of angular)
oChrome DevTools
Angular Architecture
oTwo Way Data Binding
oDirty Checking
oDependency Injection (remember)
Controllers
oControl the information that we put/edit on the page.
oTo bring controllers to life.
oDirective called ng-controller.
oHow does angular knows where does that controller live?
oCreating a function that angular will invoke.
oAlways pass the parameter to a controller name $scope which will hold the info.
o$scope is not the model but info we attached to the model
Controllers Capabilities
oAngular passes the controller function and it manipulate the $scope
oNotice how the controller never has to communicate with the html.
View
Controller
Model
Controllers Capabilities con.
oThis will create a great separation between the model and the view.
ojQuery is different.
oOn larger applications you might need multiple controllers
oDealing with complex objects
oNested controllers.
$http Service
oJust an Object that contains methods that I can use.
oEncapsulate HTTP communication (GET, POST, PUT, and DELETE).
oI can use $http inside a controller by asking for it (DI) just by adding another parameter to the
controller function.
oUsing methods like .get, .post
OR
Using an object inside $http.
oBut wait, as it’s asynchronies call, thus it returns a promise  (to make sure, use .then on that).
oBEWARE!
oExample: using $http service (GitHub API).
Modules
oBuilding a controller in the global namespace is really bad approach (remember!).
oAngular 1.3 and above prevent this by default.
oJust use module please.
oModule pattern, revealing module pattern, and angular module. ( _ ) Mother of modules.⌐■ ■
oThey are different, but they have the same goal, which is to provide a container.
oController usually live in modules (avoiding global namespace).
oWhen do I need a module, when do I use a consisting module?
oCreate a module with a name as first parameter, and array of dependencies of that module.
oRegister your controller in the module (use .controller)
oTell Angular to use your module with `ng-app`.
Directives and Views
oBinding directives, model directives, event directives, and display directives.
o`ng-app` and `ng-controller` are directives.
oDirectives to handle a button click for example.
oReminder: Model doesn’t touch the HTML directly.
oUse a binding directive to attach the data to the html (meet `ng-bind`).
oThis called Data Binding Directive.
oData binding moves model data to the view.
o`ng-src` and `ng-href`.
Directives and Views con.
oSeparation in concern.
oThe controller and the model focus on the data, while the view only shows those data.
oBut if I want to send information from the user view?
oDirectives allow that also (indirect model view interaction). We have directives that move data
from the view to the model also.
o`ng-model`.
o`ng-click` and `ng-submit`.
Filters
oBasic format: expression | filterName:parameter
o`ng-repeat` to loop.
oSome useful filters: currency, date, filter, limitTo, lowercase, uppercase, number, orderBy, and
json (for debugging).
More Directives
o`ng-show` and `ng-hide` (boolean).
o`ng-include` to include HTML partials.
o`ng-class`, `ng-disable`, `ng-focus`, and `ng-style` (same as they indicate).
o`ng-mouseleave`, `ng-mousemove`, `ng-mouseenter`, and `ng-dblclick` (mouse events).
o`ng-keypress`, `ng-keyup` (keyboard/keypad events).
IE Custom Tag Restrictions
oლ(ಠ 益 ಠლ) Y U NO SUPPORT IT?
o4 ways to “directive” (not applied for all directives though. More info on AngularJS website).
oTag name: <ng-*></ng-*>
oAttribute name: <div ng-*=“…”>…</div>, <div ng:*=“…”>…</div>, <div ng_*=“…”>…</div>,
<div data-ng-*=“…”>…</div>, <div x-ng-*=“…”>…</div>
oUse the data-* for HTML validation.
oClass name: <div class=“ng-*”></div>
oHTML Comments.
oPrefer using directives via tag name and attributes over comment and class names.
Services
oAngular comes with a lot of services and ability to build your own.
oServices like: sending http requests, computing a hash of a string, saving data into local storage,
manage cookies sent from the server, performing a validation checks… etc.
oController and directives use services.
oBuilt-in services like: $http, $interval, $window, $browser, $anchorScroll, $location, $log,
$timeout, $animate… etc.
oNotice that everything relate to angular (built-in functionality) starts with `$`, like the services
above.
o$log service can be reprogrammed to send information to the server, which will make it easier
to track the problem that the user is having.
Services con.
oThere are UI related services.
oWhen you want to force the user to navigate to a new URL.
oPop –up a model dialog to force the user to type data before taking any action.
oBEWARE!
oThe solution to these scenarios is still not to touch UI related objects directly from the model,
but instead using services that can wrap this functionality.
o$location and $anchorScroll
oWhy building your own service? Create reusable logic, create shared data, manage complexity.
Routing
oNavigate between views.
oPass parameters between views.
oUse backward and forward (the history of the browser is synchronized with the user)
oWhy? Not putting all the functionality in one view and one controller.
oRouting based on URL.
oRouting engine captures request.
oRouting rules render a response.
oHow does the routing work with angular?
Routing con.
oYou have to include another module `ngRoute` (in angular-route.js)
oConfigure rules into $routeProvider (.config).
oUsing .when and .otherwise to assign the URL and the controller for each view.
oSetup a layout view.
o`ng-view` for all.
References
oAngularJS (https://angularjs.org/)
oData Binding – AngularJs (https://docs.angularjs.org/guide/databinding)
oControllers – AngularJS (https://docs.angularjs.org/guide/controller)
o$http – AngularJS (https://docs.angularjs.org/api/ng/service/$http)
oModules – AngularJS (https://docs.angularjs.org/guide/module)
oDirectives – AngularJS (https://docs.angularjs.org/api/ng/directive)
oFilters – AngularJS (https://docs.angularjs.org/guide/filter)
oServices – AngularJS (https://docs.angularjs.org/guide/services)
ongRoute – AngularJS (https://docs.angularjs.org/api/ngRoute)

More Related Content

What's hot

AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish MinutesDan Wahlin
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS introdizabl
 
Angular js for beginners
Angular js for beginnersAngular js for beginners
Angular js for beginnersMunir Hoque
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - IntroductionSagar Acharya
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular jsTamer Solieman
 
From zero to hero with the reactive extensions for java script
From zero to hero with the reactive extensions for java scriptFrom zero to hero with the reactive extensions for java script
From zero to hero with the reactive extensions for java scriptMaurice De Beijer [MVP]
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practicesHenry Tao
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSSimon Guest
 
Angular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решенияAngular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решенияOlga Lavrentieva
 
Filters in AngularJS
Filters in AngularJSFilters in AngularJS
Filters in AngularJSBrajesh Yadav
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introductionLuigi De Russis
 
Integrating Angular js & three.js
Integrating Angular js & three.jsIntegrating Angular js & three.js
Integrating Angular js & three.jsJosh Staples
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJSBrajesh Yadav
 

What's hot (20)

AngularJS Framework
AngularJS FrameworkAngularJS Framework
AngularJS Framework
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
 
Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS intro
 
Angular js for beginners
Angular js for beginnersAngular js for beginners
Angular js for beginners
 
Angular js
Angular jsAngular js
Angular js
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
From zero to hero with the reactive extensions for java script
From zero to hero with the reactive extensions for java scriptFrom zero to hero with the reactive extensions for java script
From zero to hero with the reactive extensions for java script
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practices
 
Built in filters
Built in filtersBuilt in filters
Built in filters
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
 
AngularJS Basic Training
AngularJS Basic TrainingAngularJS Basic Training
AngularJS Basic Training
 
Angular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решенияAngular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решения
 
Filters in AngularJS
Filters in AngularJSFilters in AngularJS
Filters in AngularJS
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
Integrating Angular js & three.js
Integrating Angular js & three.jsIntegrating Angular js & three.js
Integrating Angular js & three.js
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJS
 

Viewers also liked

Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScriptAnass90
 
Trends and innovations in web development course
Trends and innovations in web development course Trends and innovations in web development course
Trends and innovations in web development course Dr. Shikha Mehta
 
League of extraordinary front end dev tools
League of extraordinary front end dev toolsLeague of extraordinary front end dev tools
League of extraordinary front end dev toolsSherif Tariq
 
Front-end Web Dev (HK) Info Session
Front-end Web Dev (HK) Info SessionFront-end Web Dev (HK) Info Session
Front-end Web Dev (HK) Info SessionAllison Baum
 
Complete Web Development Course - Make Cash Earning Websites
Complete Web Development Course - Make Cash Earning WebsitesComplete Web Development Course - Make Cash Earning Websites
Complete Web Development Course - Make Cash Earning Websitesbuenosdias1989
 
Introduction to Front End Engineering
Introduction to Front End EngineeringIntroduction to Front End Engineering
Introduction to Front End EngineeringMark Meeker
 
Front-end Engineering Concepts
Front-end Engineering ConceptsFront-end Engineering Concepts
Front-end Engineering ConceptsSameer Karve
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design PatternSanae BEKKAR
 
Class 1 - World Wide Web Introduction
Class 1 - World Wide Web IntroductionClass 1 - World Wide Web Introduction
Class 1 - World Wide Web IntroductionAhmed Swilam
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHPAhmed Swilam
 
Web Application Performance
Web Application PerformanceWeb Application Performance
Web Application PerformanceCodeFireTech
 

Viewers also liked (12)

Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
BMSHanna_N_CV
BMSHanna_N_CVBMSHanna_N_CV
BMSHanna_N_CV
 
Trends and innovations in web development course
Trends and innovations in web development course Trends and innovations in web development course
Trends and innovations in web development course
 
League of extraordinary front end dev tools
League of extraordinary front end dev toolsLeague of extraordinary front end dev tools
League of extraordinary front end dev tools
 
Front-end Web Dev (HK) Info Session
Front-end Web Dev (HK) Info SessionFront-end Web Dev (HK) Info Session
Front-end Web Dev (HK) Info Session
 
Complete Web Development Course - Make Cash Earning Websites
Complete Web Development Course - Make Cash Earning WebsitesComplete Web Development Course - Make Cash Earning Websites
Complete Web Development Course - Make Cash Earning Websites
 
Introduction to Front End Engineering
Introduction to Front End EngineeringIntroduction to Front End Engineering
Introduction to Front End Engineering
 
Front-end Engineering Concepts
Front-end Engineering ConceptsFront-end Engineering Concepts
Front-end Engineering Concepts
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 
Class 1 - World Wide Web Introduction
Class 1 - World Wide Web IntroductionClass 1 - World Wide Web Introduction
Class 1 - World Wide Web Introduction
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
 
Web Application Performance
Web Application PerformanceWeb Application Performance
Web Application Performance
 

Similar to Introduction to AngularJS

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 2014Sarah Hudson
 
Angular js interview question answer for fresher
Angular js interview question answer for fresherAngular js interview question answer for fresher
Angular js interview question answer for fresherRavi Bhadauria
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to AngularjsGaurav Agrawal
 
Angular Project Report
 Angular Project Report Angular Project Report
Angular Project ReportKodexhub
 
Everything You Need To Know About AngularJS
Everything You Need To Know About AngularJSEverything You Need To Know About AngularJS
Everything You Need To Know About AngularJSSina Mirhejazi
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionOleksii Prohonnyi
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIEric Wise
 
AngularJS Introduction (Talk given on Aug 5 2013)
AngularJS Introduction (Talk given on Aug 5 2013)AngularJS Introduction (Talk given on Aug 5 2013)
AngularJS Introduction (Talk given on Aug 5 2013)Abhishek Anand
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basicsRavindra K
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Arunangsu Sahu
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development GuideNitin Giri
 
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 conceptsSuresh Patidar
 
Integrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMSIntegrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMSTom Borger
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJSShyjal Raazi
 

Similar to Introduction to AngularJS (20)

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
 
Itroducing Angular JS
Itroducing Angular JSItroducing Angular JS
Itroducing Angular JS
 
Angular js interview question answer for fresher
Angular js interview question answer for fresherAngular js interview question answer for fresher
Angular js interview question answer for fresher
 
Intro to AngularJs
Intro to AngularJsIntro to AngularJs
Intro to AngularJs
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
Angular Project Report
 Angular Project Report Angular Project Report
Angular Project Report
 
Everything You Need To Know About AngularJS
Everything You Need To Know About AngularJSEverything You Need To Know About AngularJS
Everything You Need To Know About AngularJS
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: Introduction
 
Training On Angular Js
Training On Angular JsTraining On Angular Js
Training On Angular Js
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPI
 
AngularJS Introduction (Talk given on Aug 5 2013)
AngularJS Introduction (Talk given on Aug 5 2013)AngularJS Introduction (Talk given on Aug 5 2013)
AngularJS Introduction (Talk given on Aug 5 2013)
 
AngularJS
AngularJSAngularJS
AngularJS
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basics
 
AngularJs
AngularJsAngularJs
AngularJs
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 
Angular js
Angular jsAngular js
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
 
Integrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMSIntegrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMS
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 

Recently uploaded

10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Call Girls in Nagpur High Profile
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
SEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistSEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistKHM Anwar
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Standkumarajju5765
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 

Recently uploaded (20)

10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Call Girls In Noida 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Noida 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In Noida 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Noida 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
SEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistSEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization Specialist
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 

Introduction to AngularJS

  • 1. UP AND RUNNING WITH FRONT END WEB DEVELOPMENT ANGULARJS
  • 2. Requirements oAngularJS has no dependencies on any other libraries or framework. oAdd `ng-app` attribute in your HTML (angular directive, ng is a short of angular) oChrome DevTools
  • 3. Angular Architecture oTwo Way Data Binding oDirty Checking oDependency Injection (remember)
  • 4. Controllers oControl the information that we put/edit on the page. oTo bring controllers to life. oDirective called ng-controller. oHow does angular knows where does that controller live? oCreating a function that angular will invoke. oAlways pass the parameter to a controller name $scope which will hold the info. o$scope is not the model but info we attached to the model
  • 5. Controllers Capabilities oAngular passes the controller function and it manipulate the $scope oNotice how the controller never has to communicate with the html. View Controller Model
  • 6. Controllers Capabilities con. oThis will create a great separation between the model and the view. ojQuery is different. oOn larger applications you might need multiple controllers oDealing with complex objects oNested controllers.
  • 7. $http Service oJust an Object that contains methods that I can use. oEncapsulate HTTP communication (GET, POST, PUT, and DELETE). oI can use $http inside a controller by asking for it (DI) just by adding another parameter to the controller function. oUsing methods like .get, .post OR Using an object inside $http. oBut wait, as it’s asynchronies call, thus it returns a promise  (to make sure, use .then on that). oBEWARE! oExample: using $http service (GitHub API).
  • 8. Modules oBuilding a controller in the global namespace is really bad approach (remember!). oAngular 1.3 and above prevent this by default. oJust use module please. oModule pattern, revealing module pattern, and angular module. ( _ ) Mother of modules.⌐■ ■ oThey are different, but they have the same goal, which is to provide a container. oController usually live in modules (avoiding global namespace). oWhen do I need a module, when do I use a consisting module? oCreate a module with a name as first parameter, and array of dependencies of that module. oRegister your controller in the module (use .controller) oTell Angular to use your module with `ng-app`.
  • 9. Directives and Views oBinding directives, model directives, event directives, and display directives. o`ng-app` and `ng-controller` are directives. oDirectives to handle a button click for example. oReminder: Model doesn’t touch the HTML directly. oUse a binding directive to attach the data to the html (meet `ng-bind`). oThis called Data Binding Directive. oData binding moves model data to the view. o`ng-src` and `ng-href`.
  • 10. Directives and Views con. oSeparation in concern. oThe controller and the model focus on the data, while the view only shows those data. oBut if I want to send information from the user view? oDirectives allow that also (indirect model view interaction). We have directives that move data from the view to the model also. o`ng-model`. o`ng-click` and `ng-submit`.
  • 11. Filters oBasic format: expression | filterName:parameter o`ng-repeat` to loop. oSome useful filters: currency, date, filter, limitTo, lowercase, uppercase, number, orderBy, and json (for debugging).
  • 12. More Directives o`ng-show` and `ng-hide` (boolean). o`ng-include` to include HTML partials. o`ng-class`, `ng-disable`, `ng-focus`, and `ng-style` (same as they indicate). o`ng-mouseleave`, `ng-mousemove`, `ng-mouseenter`, and `ng-dblclick` (mouse events). o`ng-keypress`, `ng-keyup` (keyboard/keypad events).
  • 13. IE Custom Tag Restrictions oლ(ಠ 益 ಠლ) Y U NO SUPPORT IT? o4 ways to “directive” (not applied for all directives though. More info on AngularJS website). oTag name: <ng-*></ng-*> oAttribute name: <div ng-*=“…”>…</div>, <div ng:*=“…”>…</div>, <div ng_*=“…”>…</div>, <div data-ng-*=“…”>…</div>, <div x-ng-*=“…”>…</div> oUse the data-* for HTML validation. oClass name: <div class=“ng-*”></div> oHTML Comments. oPrefer using directives via tag name and attributes over comment and class names.
  • 14. Services oAngular comes with a lot of services and ability to build your own. oServices like: sending http requests, computing a hash of a string, saving data into local storage, manage cookies sent from the server, performing a validation checks… etc. oController and directives use services. oBuilt-in services like: $http, $interval, $window, $browser, $anchorScroll, $location, $log, $timeout, $animate… etc. oNotice that everything relate to angular (built-in functionality) starts with `$`, like the services above. o$log service can be reprogrammed to send information to the server, which will make it easier to track the problem that the user is having.
  • 15. Services con. oThere are UI related services. oWhen you want to force the user to navigate to a new URL. oPop –up a model dialog to force the user to type data before taking any action. oBEWARE! oThe solution to these scenarios is still not to touch UI related objects directly from the model, but instead using services that can wrap this functionality. o$location and $anchorScroll oWhy building your own service? Create reusable logic, create shared data, manage complexity.
  • 16. Routing oNavigate between views. oPass parameters between views. oUse backward and forward (the history of the browser is synchronized with the user) oWhy? Not putting all the functionality in one view and one controller. oRouting based on URL. oRouting engine captures request. oRouting rules render a response. oHow does the routing work with angular?
  • 17. Routing con. oYou have to include another module `ngRoute` (in angular-route.js) oConfigure rules into $routeProvider (.config). oUsing .when and .otherwise to assign the URL and the controller for each view. oSetup a layout view. o`ng-view` for all.
  • 18. References oAngularJS (https://angularjs.org/) oData Binding – AngularJs (https://docs.angularjs.org/guide/databinding) oControllers – AngularJS (https://docs.angularjs.org/guide/controller) o$http – AngularJS (https://docs.angularjs.org/api/ng/service/$http) oModules – AngularJS (https://docs.angularjs.org/guide/module) oDirectives – AngularJS (https://docs.angularjs.org/api/ng/directive) oFilters – AngularJS (https://docs.angularjs.org/guide/filter) oServices – AngularJS (https://docs.angularjs.org/guide/services) ongRoute – AngularJS (https://docs.angularjs.org/api/ngRoute)

Editor's Notes

  1. **Simple Example** &amp;lt;body ng-app&amp;gt; {{1+2}} &amp;lt;/body&amp;gt; =&amp;gt; &amp;lt;div ng-app&amp;gt;&amp;lt;/div&amp;gt;
  2. **Main View** &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; {{message}} &amp;lt;/div&amp;gt; **Controller** var MainController = function($scope) { $scope.message = &amp;apos;Hello World!&amp;apos;; }
  3. **Controller** var MainController = function($scope) { var person = { fname: &amp;apos;Anas&amp;apos;, lname: &amp;apos;Shekhamis&amp;apos;, img: &amp;apos;https://pbs.twimg.com/profile_images/461250252507328512/a8L2fwnk.png&amp;apos; } $scope.person = person; $scope.message = &amp;apos;Hello World!&amp;apos;; } **View** &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; {{message}} Name is: {{person.fname}} {{person.lname}} &amp;lt;br&amp;gt; &amp;lt;img ng-src=&amp;quot;{{person.img}}&amp;quot; alt=&amp;quot;{{person.fname}} {{person.lname}}&amp;quot; title=&amp;quot;{{person.fname}} {{person.lname}}&amp;quot; /&amp;gt; &amp;lt;/div&amp;gt;
  4. **Controller** var MainController = function($scope, $http) { var onUserComplete = function (response) { $scope.user = response.data; }, onError = function(reason) { $scope.error = &amp;quot;Could not fetch the user!&amp;quot;; } $http.get(&amp;quot;https://api.github.com/users/angular&amp;quot;) .then(onUserComplete, onError); } **View** &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; &amp;lt;p&amp;gt; {{error}} &amp;lt;/p&amp;gt; Name: {{user.name}} &amp;lt;br&amp;gt; Link on GitHub: &amp;lt;a ng-href=&amp;quot;{{user.html_url}}&amp;quot;&amp;gt;{{user.name}}&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt; &amp;lt;img ng-src=&amp;quot;{{user.avatar_url}}&amp;quot; title=&amp;quot;{{user.name}}&amp;quot; /&amp;gt; &amp;lt;/div&amp;gt;
  5. **Module** var github = angular.module(‘githubAPI&amp;apos;, []); **Controller** var MainController = function($scope, $http) { var onUserComplete = function (response) { $scope.user = response.data; }, onError = function(reason) { $scope.error = &amp;quot;Could not fetch the user!&amp;quot;; } $http.get(&amp;quot;https://api.github.com/users/angular&amp;quot;) .then(onUserComplete, onError); } **Assigning the controller** github.controller(&amp;apos;MainController&amp;apos;, MainController); **View** &amp;lt;div ng-app=“githubAPI&amp;quot;&amp;gt; &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; &amp;lt;p&amp;gt; {{error}} &amp;lt;/p&amp;gt; Name: {{user.name}} &amp;lt;br&amp;gt; Link on GitHub: &amp;lt;a ng-href=&amp;quot;{{user.html_url}}&amp;quot;&amp;gt;{{user.name}}&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt; &amp;lt;img ng-src=&amp;quot;{{user.avatar_url}}&amp;quot; title=&amp;quot;{{user.name}}&amp;quot; /&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt;
  6. **View (example 1)** &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; &amp;lt;p&amp;gt; {{error}} &amp;lt;/p&amp;gt; &amp;lt;form name=&amp;quot;searchUser&amp;quot;&amp;gt; Search User:&amp;lt;input type=&amp;quot;search&amp;quot; ng-model=&amp;quot;username&amp;quot; placeholder=&amp;quot;Username to find!&amp;quot; /&amp;gt; &amp;lt;span&amp;gt;{{username}}&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt; &amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;search&amp;lt;/button&amp;gt; &amp;lt;/form&amp;gt; Name: {{user.name}} &amp;lt;br&amp;gt; Link on GitHub: &amp;lt;a ng-href=&amp;quot;{{user.html_url}}&amp;quot;&amp;gt;{{user.name}}&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt; &amp;lt;img ng-src=&amp;quot;{{user.avatar_url}}&amp;quot; title=&amp;quot;{{user.name}}&amp;quot; /&amp;gt; &amp;lt;/div&amp;gt; **View (example 2)** &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; &amp;lt;p&amp;gt; {{error}} &amp;lt;/p&amp;gt; &amp;lt;form name=&amp;quot;searchUser&amp;quot;&amp;gt; Search User:&amp;lt;input type=&amp;quot;search&amp;quot; ng-model=&amp;quot;username&amp;quot; placeholder=&amp;quot;Username to find!&amp;quot; /&amp;gt; &amp;lt;span&amp;gt;{{username}}&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt; &amp;lt;button type=&amp;quot;submit&amp;quot; ng-click=&amp;quot;search(username)&amp;quot;&amp;gt;search&amp;lt;/button&amp;gt; &amp;lt;/form&amp;gt; Name: {{user.name}} &amp;lt;br&amp;gt; Link on GitHub: &amp;lt;a ng-href=&amp;quot;{{user.html_url}}&amp;quot;&amp;gt;{{user.name}}&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt; &amp;lt;img ng-src=&amp;quot;{{user.avatar_url}}&amp;quot; title=&amp;quot;{{user.name}}&amp;quot; /&amp;gt; &amp;lt;/div&amp;gt; **View (example 3)** &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; &amp;lt;p&amp;gt; {{error}} &amp;lt;/p&amp;gt; &amp;lt;form name=&amp;quot;searchUser&amp;quot; ng-submit=&amp;quot;search(username)&amp;quot;&amp;gt; Search User:&amp;lt;input type=&amp;quot;search&amp;quot; ng-model=&amp;quot;username&amp;quot; placeholder=&amp;quot;Username to find!&amp;quot; required /&amp;gt; &amp;lt;span&amp;gt;{{username}}&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt; &amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;search&amp;lt;/button&amp;gt; &amp;lt;/form&amp;gt; Name: {{user.name}} &amp;lt;br&amp;gt; Link on GitHub: &amp;lt;a ng-href=&amp;quot;{{user.html_url}}&amp;quot;&amp;gt;{{user.name}}&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt; &amp;lt;img ng-src=&amp;quot;{{user.avatar_url}}&amp;quot; title=&amp;quot;{{user.name}}&amp;quot; /&amp;gt; &amp;lt;/div&amp;gt;
  7. **Controller** var MainController = function($scope, $http) { var onUserComplete = function (response) { $scope.user = response.data; $http.get($scope.user.repos_url) .then(onRepos, onError); }, onError = function(reason) { $scope.error = &amp;quot;Could not fetch the data!&amp;quot;; }, onRepos = function(response) { $scope.repos = response.data; }; $scope.username = &amp;apos;angular&amp;apos;; $scope.reposSort = &amp;quot;-stargazers_count&amp;quot;; $scope.search = function(username) { $http.get(&amp;quot;https://api.github.com/users/&amp;quot; + username) .then(onUserComplete, onError); } } **View** &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; &amp;lt;p&amp;gt; {{error}} &amp;lt;/p&amp;gt; &amp;lt;form name=&amp;quot;searchUser&amp;quot; ng-submit=&amp;quot;search(username)&amp;quot;&amp;gt; Search User:&amp;lt;input type=&amp;quot;search&amp;quot; ng-model=&amp;quot;username&amp;quot; placeholder=&amp;quot;Username to find!&amp;quot; required /&amp;gt; &amp;lt;span&amp;gt;{{username}}&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt; &amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;search&amp;lt;/button&amp;gt; &amp;lt;/form&amp;gt; &amp;lt;h1&amp;gt;&amp;lt;a ng-href=&amp;quot;{{user.html_url}}&amp;quot;&amp;gt;{{user.name}}&amp;lt;/a&amp;gt; (created at: {{user.created_at | date:&amp;apos;short&amp;apos;}})&amp;lt;/h1&amp;gt; &amp;lt;img ng-src=&amp;quot;{{user.avatar_url}}&amp;quot; title=&amp;quot;{{user.name}}&amp;quot; /&amp;gt; &amp;lt;br&amp;gt; &amp;lt;h3&amp;gt;Repos&amp;lt;/h3&amp;gt; &amp;lt;input type=&amp;quot;search&amp;quot; placeholder=&amp;quot;search by repo name&amp;quot; ng-model=&amp;quot;searchTerm&amp;quot; /&amp;gt; Order: &amp;lt;select ng-model=&amp;quot;reposSort&amp;quot;&amp;gt; &amp;lt;option value=&amp;quot;+name&amp;quot;&amp;gt;Name&amp;lt;/option&amp;gt; &amp;lt;option value=&amp;quot;-stargazers_count&amp;quot;&amp;gt;Stars&amp;lt;/option&amp;gt; &amp;lt;option value=&amp;quot;+language&amp;quot;&amp;gt;Language&amp;lt;/option&amp;gt; &amp;lt;/select&amp;gt; &amp;lt;table&amp;gt; &amp;lt;thead&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt; &amp;lt;th&amp;gt;Stars&amp;lt;/th&amp;gt; &amp;lt;th&amp;gt;Language&amp;lt;/th&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/thead&amp;gt; &amp;lt;tbody&amp;gt; &amp;lt;tr ng-repeat=&amp;quot;repo in repos | filter:searchTerm | orderBy:reposSort&amp;quot;&amp;gt; &amp;lt;td&amp;gt;{{repo.name | uppercase}}&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;{{repo.stargazers_count | number}}&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;{{repo.language}}&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/tbody&amp;gt; &amp;lt;/table&amp;gt; &amp;lt;/div&amp;gt;
  8. **View** &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; &amp;lt;p&amp;gt; {{error}} &amp;lt;/p&amp;gt; &amp;lt;form name=&amp;quot;searchUser&amp;quot; ng-submit=&amp;quot;search(username)&amp;quot;&amp;gt; Search User: &amp;lt;input type=&amp;quot;search&amp;quot; ng-model=&amp;quot;username&amp;quot; placeholder=&amp;quot;Username to find!&amp;quot; required /&amp;gt; &amp;lt;span&amp;gt;{{username}}&amp;lt;/span&amp;gt; &amp;lt;br&amp;gt; &amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;search&amp;lt;/button&amp;gt; &amp;lt;/form&amp;gt; &amp;lt;div ng-show=&amp;quot;user&amp;quot;&amp;gt; &amp;lt;h1&amp;gt;&amp;lt;a ng-href=&amp;quot;{{user.html_url}}&amp;quot;&amp;gt;{{user.name}}&amp;lt;/a&amp;gt; (created at: {{user.created_at | date:&amp;apos;short&amp;apos;}})&amp;lt;/h1&amp;gt; &amp;lt;img ng-src=&amp;quot;{{user.avatar_url}}&amp;quot; title=&amp;quot;{{user.name}}&amp;quot; /&amp;gt; &amp;lt;br&amp;gt; &amp;lt;h3&amp;gt;Repos&amp;lt;/h3&amp;gt; &amp;lt;input type=&amp;quot;search&amp;quot; placeholder=&amp;quot;search by repo name&amp;quot; ng-model=&amp;quot;searchTerm&amp;quot; /&amp;gt; Order: &amp;lt;select ng-model=&amp;quot;reposSort&amp;quot;&amp;gt; &amp;lt;option value=&amp;quot;+name&amp;quot;&amp;gt;Name&amp;lt;/option&amp;gt; &amp;lt;option value=&amp;quot;-stargazers_count&amp;quot;&amp;gt;Stars&amp;lt;/option&amp;gt; &amp;lt;option value=&amp;quot;+language&amp;quot;&amp;gt;Language&amp;lt;/option&amp;gt; &amp;lt;/select&amp;gt; &amp;lt;table ng-show=&amp;quot;repos&amp;quot;&amp;gt; &amp;lt;thead&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt; &amp;lt;th&amp;gt;Stars&amp;lt;/th&amp;gt; &amp;lt;th&amp;gt;Language&amp;lt;/th&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/thead&amp;gt; &amp;lt;tbody&amp;gt; &amp;lt;tr ng-repeat=&amp;quot;repo in repos | filter:searchTerm | orderBy:reposSort&amp;quot;&amp;gt; &amp;lt;td&amp;gt;{{repo.name | uppercase}}&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;{{repo.stargazers_count | number}}&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;{{repo.language}}&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/tbody&amp;gt; &amp;lt;/table&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt; -------------------------------------------------------------- **Main View** &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; &amp;lt;p&amp;gt; {{error}} &amp;lt;/p&amp;gt; &amp;lt;form name=&amp;quot;searchUser&amp;quot; ng-submit=&amp;quot;search(username)&amp;quot;&amp;gt; Search User: &amp;lt;input type=&amp;quot;search&amp;quot; ng-model=&amp;quot;username&amp;quot; placeholder=&amp;quot;Username to find!&amp;quot; required /&amp;gt; &amp;lt;span&amp;gt;{{username}}&amp;lt;/span&amp;gt; &amp;lt;br&amp;gt; &amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;search&amp;lt;/button&amp;gt; &amp;lt;/form&amp;gt; &amp;lt;div ng-include=&amp;quot;&amp;apos;userdetails.html&amp;apos;&amp;quot; ng-show=&amp;quot;user&amp;quot;&amp;gt;&amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt; **Partial View (to be included)** &amp;lt;h1&amp;gt;&amp;lt;a ng-href=&amp;quot;{{user.html_url}}&amp;quot;&amp;gt;{{user.name}}&amp;lt;/a&amp;gt; (created at: {{user.created_at | date:&amp;apos;short&amp;apos;}})&amp;lt;/h1&amp;gt; &amp;lt;img ng-src=&amp;quot;{{user.avatar_url}}&amp;quot; title=&amp;quot;{{user.name}}&amp;quot; /&amp;gt; &amp;lt;br&amp;gt; &amp;lt;h3&amp;gt;Repos&amp;lt;/h3&amp;gt; &amp;lt;input type=&amp;quot;search&amp;quot; placeholder=&amp;quot;search by repo name&amp;quot; ng-model=&amp;quot;searchTerm&amp;quot; /&amp;gt; Order: &amp;lt;select ng-model=&amp;quot;reposSort&amp;quot;&amp;gt; &amp;lt;option value=&amp;quot;+name&amp;quot;&amp;gt;Name&amp;lt;/option&amp;gt; &amp;lt;option value=&amp;quot;-stargazers_count&amp;quot;&amp;gt;Stars&amp;lt;/option&amp;gt; &amp;lt;option value=&amp;quot;+language&amp;quot;&amp;gt;Language&amp;lt;/option&amp;gt; &amp;lt;/select&amp;gt; &amp;lt;table ng-show=&amp;quot;repos&amp;quot;&amp;gt; &amp;lt;thead&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt; &amp;lt;th&amp;gt;Stars&amp;lt;/th&amp;gt; &amp;lt;th&amp;gt;Language&amp;lt;/th&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/thead&amp;gt; &amp;lt;tbody&amp;gt; &amp;lt;tr ng-repeat=&amp;quot;repo in repos | filter:searchTerm | orderBy:reposSort&amp;quot;&amp;gt; &amp;lt;td&amp;gt;{{repo.name | uppercase}}&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;{{repo.stargazers_count | number}}&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;{{repo.language}}&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/tbody&amp;gt; &amp;lt;/table&amp;gt;
  9. **Controller** var MainController = function ($scope, $http, $interval, $log) { var onUserComplete = function (response) { $scope.user = response.data; $http.get($scope.user.repos_url) .then(onRepos, onError); }, onError = function (reason) { $scope.error = &amp;quot;Could not fetch the data!&amp;quot;; }, onRepos = function (response) { $scope.repos = response.data; }, decrementCountdown = function () { $scope.countdown--; if ($scope.countdown &amp;lt; 1) { $scope.search($scope.username); } }, countdownInterval = null, startCountdown = function () { countdownInterval = $interval(decrementCountdown, 1000, $scope.countdown); }; $scope.search = function (username) { $log.info(&amp;apos;Searching for &amp;apos;+username); $http.get(&amp;quot;https://api.github.com/users/&amp;quot; + username) .then(onUserComplete, onError); if(countdownInterval) { $interval.cancel(countdownInterval); $scope.countdown = null; } } $scope.username = &amp;apos;angular&amp;apos;; $scope.reposSort = &amp;quot;-stargazers_count&amp;quot;; $scope.countdown = 5; startCountdown(); } **Main View** &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; &amp;lt;p&amp;gt; {{error}} &amp;lt;/p&amp;gt; &amp;lt;br&amp;gt; {{countdown}} &amp;lt;form name=&amp;quot;searchUser&amp;quot; ng-submit=&amp;quot;search(username)&amp;quot;&amp;gt; Search User: &amp;lt;input type=&amp;quot;search&amp;quot; ng-model=&amp;quot;username&amp;quot; placeholder=&amp;quot;Username to find!&amp;quot; required /&amp;gt; &amp;lt;span&amp;gt;{{username}}&amp;lt;/span&amp;gt; &amp;lt;br&amp;gt; &amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;search&amp;lt;/button&amp;gt; &amp;lt;/form&amp;gt; &amp;lt;div ng-include=&amp;quot;&amp;apos;userdetails.html&amp;apos;&amp;quot; ng-show=&amp;quot;user&amp;quot;&amp;gt;&amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt;
  10. **Controller** var MainController = function ($scope, $http, $interval, $log, $anchorScroll, $location) { var onUserComplete = function (response) { $scope.user = response.data; $http.get($scope.user.repos_url) .then(onRepos, onError); }, onError = function (reason) { $scope.error = &amp;quot;Could not fetch the data!&amp;quot;; }, onRepos = function (response) { $scope.repos = response.data; $location.hash(&amp;apos;userDetails&amp;apos;); $anchorScroll(); }, decrementCountdown = function () { $scope.countdown--; if ($scope.countdown &amp;lt; 1) { $scope.search($scope.username); } }, countdownInterval = null, startCountdown = function () { countdownInterval = $interval(decrementCountdown, 1000, $scope.countdown); }; $scope.search = function (username) { $log.info(&amp;apos;Searching for &amp;apos;+username); $http.get(&amp;quot;https://api.github.com/users/&amp;quot; + username) .then(onUserComplete, onError); if(countdownInterval) { $interval.cancel(countdownInterval); $scope.countdown = null; } } $scope.username = &amp;apos;angular&amp;apos;; $scope.reposSort = &amp;quot;-stargazers_count&amp;quot;; $scope.countdown = 5; startCountdown(); } **Partial View** &amp;lt;div id=&amp;quot;userDetails&amp;quot;&amp;gt; &amp;lt;h1&amp;gt;&amp;lt;a ng-href=&amp;quot;{{user.html_url}}&amp;quot;&amp;gt;{{user.name}}&amp;lt;/a&amp;gt; (created at: {{user.created_at | date:&amp;apos;short&amp;apos;}})&amp;lt;/h1&amp;gt; &amp;lt;img ng-src=&amp;quot;{{user.avatar_url}}&amp;quot; title=&amp;quot;{{user.name}}&amp;quot; /&amp;gt; &amp;lt;br&amp;gt; &amp;lt;h3&amp;gt;Repos&amp;lt;/h3&amp;gt; &amp;lt;input type=&amp;quot;search&amp;quot; placeholder=&amp;quot;search by repo name&amp;quot; ng-model=&amp;quot;searchTerm&amp;quot; /&amp;gt; Order: &amp;lt;select ng-model=&amp;quot;reposSort&amp;quot;&amp;gt; &amp;lt;option value=&amp;quot;+name&amp;quot;&amp;gt;Name&amp;lt;/option&amp;gt; &amp;lt;option value=&amp;quot;-stargazers_count&amp;quot;&amp;gt;Stars&amp;lt;/option&amp;gt; &amp;lt;option value=&amp;quot;+language&amp;quot;&amp;gt;Language&amp;lt;/option&amp;gt; &amp;lt;/select&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;table ng-show=&amp;quot;repos&amp;quot;&amp;gt; &amp;lt;thead&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt; &amp;lt;th&amp;gt;Stars&amp;lt;/th&amp;gt; &amp;lt;th&amp;gt;Language&amp;lt;/th&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/thead&amp;gt; &amp;lt;tbody&amp;gt; &amp;lt;tr ng-repeat=&amp;quot;repo in repos | filter:searchTerm | orderBy:reposSort&amp;quot;&amp;gt; &amp;lt;td&amp;gt;{{repo.name | uppercase}}&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;{{repo.stargazers_count | number}}&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;{{repo.language}}&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/tbody&amp;gt; &amp;lt;/table&amp;gt; ----------Creating Services-------------------------------- **Conroller** var MainController = function ($scope, github, $interval, $log, $anchorScroll, $location) { var onUserComplete = function (data) { $scope.user = data; github.getRepos($scope.user).then(onRepos, onError); }, onError = function (reason) { $scope.error = &amp;quot;Could not fetch the data!&amp;quot;; }, onRepos = function (data) { $scope.repos = data; $location.hash(&amp;apos;userDetails&amp;apos;); $anchorScroll(); }, decrementCountdown = function () { $scope.countdown--; if ($scope.countdown &amp;lt; 1) { $scope.search($scope.username); } }, countdownInterval = null, startCountdown = function () { countdownInterval = $interval(decrementCountdown, 1000, $scope.countdown); }; $scope.search = function (username) { $log.info(&amp;apos;Searching for &amp;apos;+username); github.getUser(username).then(onUserComplete, onError); if(countdownInterval) { $interval.cancel(countdownInterval); $scope.countdown = null; } } $scope.username = &amp;apos;angular&amp;apos;; $scope.reposSort = &amp;quot;-stargazers_count&amp;quot;; $scope.countdown = 5; startCountdown(); } **Main View** &amp;lt;div ng-controller=&amp;quot;MainController&amp;quot;&amp;gt; &amp;lt;p&amp;gt; {{error}} &amp;lt;/p&amp;gt; &amp;lt;br&amp;gt; {{countdown}} &amp;lt;form name=&amp;quot;searchUser&amp;quot; ng-submit=&amp;quot;search(username)&amp;quot;&amp;gt; Search User: &amp;lt;input type=&amp;quot;search&amp;quot; ng-model=&amp;quot;username&amp;quot; placeholder=&amp;quot;Username to find!&amp;quot; required /&amp;gt; &amp;lt;span&amp;gt;{{username}}&amp;lt;/span&amp;gt; &amp;lt;br&amp;gt; &amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;search&amp;lt;/button&amp;gt; &amp;lt;/form&amp;gt; &amp;lt;div ng-include=&amp;quot;&amp;apos;userdetails.html&amp;apos;&amp;quot; ng-show=&amp;quot;user&amp;quot;&amp;gt;&amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt; **Services** (function () { var github = function ($http) { var getUser = function (username) { return $http.get(&amp;quot;https://api.github.com/users/&amp;quot; + username) .then(function (response) { return response.data; }); }, getRepos = function (user) { return $http.get(user.repos_url) .then(function (response) { return response.data; }); }; return { getUser: getUser, getRepos: getRepos }; } var module = angular.module(&amp;apos;githubAPI&amp;apos;); module.factory(&amp;apos;github&amp;apos;, github); }());
  11. **The final code** **Module and routeProvider Config** (function () { var githubAPI = angular.module(&amp;apos;githubAPI&amp;apos;, [&amp;apos;ngRoute&amp;apos;]); githubViewer.config(function ($routeProvider) { $routeProvider .when(&amp;apos;/main&amp;apos;, { templateUrl: &amp;quot;main.html&amp;quot;, controller: &amp;apos;MainController&amp;apos; }) .when(&amp;apos;/user/:username&amp;apos;, { templateUrl: &amp;quot;user.html&amp;quot;, controller: &amp;apos;UserController&amp;apos; }) .otherwise({ redirectTo: &amp;apos;/main&amp;apos; }) }); }()); **First Controller** var MainController = function ($scope, $interval, $location) { var decrementCountdown = function () { $scope.countdown--; if ($scope.countdown &amp;lt; 1) { $scope.search($scope.username); } }, countdownInterval = null, startCountdown = function () { countdownInterval = $interval(decrementCountdown, 1000, $scope.countdown); }; $scope.search = function (username) { if(countdownInterval) { $interval.cancel(countdownInterval); $scope.countdown = null; } $location.path(&amp;apos;/user/&amp;apos;+username); } $scope.username = &amp;apos;angular&amp;apos;; $scope.countdown = 5; startCountdown(); } **Second Controller** var UserController = function ($scope, github, $routeParams) { var onUserComplete = function (data) { $scope.user = data; github.getRepos($scope.user).then(onRepos, onError); }, onError = function (reason) { $scope.error = &amp;quot;Could not fetch the data!&amp;quot;; }, onRepos = function (data) { $scope.repos = data; }; $scope.username = $routeParams.username; $scope.reposSort = &amp;quot;-stargazers_count&amp;quot;; github.getUser($scope.username).then(onUserComplete, onError); } **Main View** &amp;lt;div ng-view&amp;gt;&amp;lt;/div&amp;gt; **First Partial View** &amp;lt;div&amp;gt; &amp;lt;br&amp;gt; {{countdown}} &amp;lt;form name=&amp;quot;searchUser&amp;quot; ng-submit=&amp;quot;search(username)&amp;quot;&amp;gt; Search User: &amp;lt;input type=&amp;quot;search&amp;quot; ng-model=&amp;quot;username&amp;quot; placeholder=&amp;quot;Username to find!&amp;quot; required /&amp;gt; &amp;lt;span&amp;gt;{{username}}&amp;lt;/span&amp;gt; &amp;lt;br&amp;gt; &amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;search&amp;lt;/button&amp;gt; &amp;lt;/form&amp;gt; &amp;lt;/div&amp;gt; **Second Partial View** &amp;lt;div&amp;gt; {{error}} &amp;lt;h1&amp;gt;&amp;lt;a ng-href=&amp;quot;{{user.html_url}}&amp;quot;&amp;gt;{{user.name}}&amp;lt;/a&amp;gt; (created at: {{user.created_at | date:&amp;apos;short&amp;apos;}})&amp;lt;/h1&amp;gt; &amp;lt;img ng-src=&amp;quot;{{user.avatar_url}}&amp;quot; title=&amp;quot;{{user.name}}&amp;quot; /&amp;gt; &amp;lt;br&amp;gt; &amp;lt;h3&amp;gt;Repos&amp;lt;/h3&amp;gt; &amp;lt;input type=&amp;quot;search&amp;quot; placeholder=&amp;quot;search by repo name&amp;quot; ng-model=&amp;quot;searchTerm&amp;quot; /&amp;gt; Order: &amp;lt;select ng-model=&amp;quot;reposSort&amp;quot;&amp;gt; &amp;lt;option value=&amp;quot;+name&amp;quot;&amp;gt;Name&amp;lt;/option&amp;gt; &amp;lt;option value=&amp;quot;-stargazers_count&amp;quot;&amp;gt;Stars&amp;lt;/option&amp;gt; &amp;lt;option value=&amp;quot;+language&amp;quot;&amp;gt;Language&amp;lt;/option&amp;gt; &amp;lt;/select&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;table ng-show=&amp;quot;repos&amp;quot;&amp;gt; &amp;lt;thead&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt; &amp;lt;th&amp;gt;Stars&amp;lt;/th&amp;gt; &amp;lt;th&amp;gt;Language&amp;lt;/th&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/thead&amp;gt; &amp;lt;tbody&amp;gt; &amp;lt;tr ng-repeat=&amp;quot;repo in repos | filter:searchTerm | orderBy:reposSort&amp;quot;&amp;gt; &amp;lt;td&amp;gt;{{repo.name | uppercase}}&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;{{repo.stargazers_count | number}}&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;{{repo.language}}&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/tbody&amp;gt; &amp;lt;/table&amp;gt; &amp;lt;br&amp;gt; &amp;lt;a href=&amp;quot;#/main&amp;quot;&amp;gt;Back To Search!&amp;lt;/a&amp;gt; **Services** (function () { var github = function ($http) { var getUser = function (username) { return $http.get(&amp;quot;https://api.github.com/users/&amp;quot; + username) .then(function (response) { return response.data; }); }, getRepos = function (user) { return $http.get(user.repos_url) .then(function (response) { return response.data; }); }; return { getUser: getUser, getRepos: getRepos }; } var module = angular.module(&amp;apos;githubAPI&amp;apos;); module.factory(&amp;apos;github&amp;apos;, github); }());