SlideShare une entreprise Scribd logo
1  sur  17
HTML enhanced for web apps!HTML enhanced for web apps!
Back in time ...
Websites instead of webapps
Client seen as an interface
All the workload handled by
the server
No client-side logic
Javascript coder seen as web
designer
… when dinosaurs rule the Earth
Getting into the present day...
AJAX – HTML5 – CSS3
Web 2.0
Client splitted from server
Lots of new Javascript libraries
Webapp
Javascript: the answer!
Javascript frameworks
MVC Architecture
Big webapp
No more comparison with
web designers!
A current problem
Too much time
Too much code
Too much stress
Building client-side
webapp is still hard
DOM Manipulation
Data validation
Angular for the life!
Data-binding
Basic templating directives
Form validation
Routing
Reusable components
Dependency injection
Unit-testing
Bootstrap
Load HTML DOM
Load the module associated with
the directive
Create the application injector
Compile the DOM treating the ng-
app directive as the root of the
compilation
Conceptual Overview
1. The browser loads the HTML and parses it
into a DOM
2. The browser loads angular.js script
3. Angular waits for DOMContentLoaded event
4. Angular looks for ng-app directive, which
designates the application boundary
5. The Module specified in ng-app (if any) is
used to configure the $injector
6. The $injector is used to create the $compile
service as well as $rootScope
7. The $compile service is used to compile the
DOM and link it with $rootScope
HTML Compiler
Compile: traverse the DOM and collect all of the directives.
The result is a linking function.
Link: combine the directives with a scope and produce a
live view. Any changes in the scope model are reflected in
the view, and any user interactions with the view are
reflected in the scope model. This makes the scope model
the single source of truth.
Compiler is an angular service which traverses the DOM looking for attributes
Data-binding
Also known as MVVM
Runtime
1. The browser's event-loop waits
for an event to arrive. An event is
a user interaction, timer event, or
network event (response from a
server)
2. The event's callback gets
executed. This enters the
JavaScript context. The callback
can modify the DOM structure
3. Once the callback executes,
the browser leaves the JavaScript
context and re-renders the view
based on DOM changes.
Runtime in detail
1. Enter Angular execution context by calling scope.
$apply(stimulusFn)
2. Angular executes the stimulusFn(), which typically modifies
application state
3. Angular enters the $digest loop. The loop is made up of two smaller
loops which process $evalAsync queue and the $watch list. The
$digest loop keeps iterating until the model stabilizes.
4. The $evalAsync queue is used to schedule work which needs to
occur outside of current stack frame, but before the browser's view
render
5. The $watch list is a set of expressions which may have changed
since last iteration. If a change is detected then the $watch function is
called which typically updates the DOM with the new value
7. Once the Angular $digest loop finishes the execution leaves the
Angular and JavaScript context. This is followed by the browser re-
rendering the DOM to reflect any changes
Scope & View
The browser parses the HTML into
the DOM, and the DOM becomes
the input to the template engine
known as the compiler. The
compiler looks for directives which
in turn set up watches on the model.
The result is a continuously
updating view which does not need
template model re-merging. Your
model becomes the single source-
of-truth for your view.
The scope is responsible for detecting changes to the model section
and provides the execution context for expressions.
Directives & Filters
A directive is a behavior or DOM transformation which is triggered by
the presence of a custom attribute, element name, or a class name. A
directive allows you to extend the HTML vocabulary in a declarative
fashion.
<input type=”text” ng-model=”user.name” placeholder=”Foo”/>
Filters perform data transformation. Typically they are used in
conjunction with the locale to format the data in locale specific output.
They follow the spirit of UNIX filters and use similar syntax | (pipe).
<div>Negative number: {{val | number:2}}</div>
<div>Your name (in lowercase): {{user.name | lowercase}}</div>
Modules & Injectors
The injector is a service locator. There
is a single injector per Angular
application. The injector provides a
way to look up an object instance by its
name. The injector keeps an internal
cache of all objects so that repeated
calls to get the same object name
result in the same instance. If the
object does not exist, then the injector
asks the instance factory to create a
new instance.
A module is a way to configure the injector's instance factory, known
as a provider.
What's next?
Forms
i18n & l10n
Modules
Dependencies
MVC
E2E Testing
Angular Services
etc etc etc
The End

Contenu connexe

Tendances

Building scalable applications with angular js
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular jsAndrew Alpert
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)Gary Arora
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practicesHenry Tao
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introductionTania Gonzales
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Sumanth Chinthagunta
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - IntroductionSagar Acharya
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJSWei Ru
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developersYakov Fain
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIVisual Engineering
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIVisual Engineering
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJSRan Mizrahi
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2Knoldus Inc.
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsRapidValue
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JSBipin
 

Tendances (20)

Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
Angular js
Angular jsAngular js
Angular js
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
Building scalable applications with angular js
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular js
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practices
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developers
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte III
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJS
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue Solutions
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
 

Similaire à Angularjs

Client Side MVC & Angular
Client Side MVC & AngularClient Side MVC & Angular
Client Side MVC & AngularAlexe Bogdan
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesMohamad Al Asmar
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN StackRob Davarnia
 
AngularJS - Javascript framework for superheroes
AngularJS - Javascript framework for superheroesAngularJS - Javascript framework for superheroes
AngularJS - Javascript framework for superheroesVincenzo Ferrari
 
Angular JS - Javascript framework for superheroes
Angular JS - Javascript framework for superheroesAngular JS - Javascript framework for superheroes
Angular JS - Javascript framework for superheroesEugenio Minardi
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to AngularjsGaurav Agrawal
 
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarIntroduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarAppfinz Technologies
 
Android chapter16-web-services
Android chapter16-web-servicesAndroid chapter16-web-services
Android chapter16-web-servicesAravindharamanan S
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desaijinaldesailive
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular jsAayush Shrestha
 
Angular.js interview questions
Angular.js interview questionsAngular.js interview questions
Angular.js interview questionscodeandyou forums
 
.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQ.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQAvijit Shaw
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkbanq jdon
 
Modern webtechnologies
Modern webtechnologiesModern webtechnologies
Modern webtechnologiesBesjan Xhika
 
Advanced web application architecture Way2Web
Advanced web application architecture Way2WebAdvanced web application architecture Way2Web
Advanced web application architecture Way2WebMatthias Noback
 

Similaire à Angularjs (20)

Client Side MVC & Angular
Client Side MVC & AngularClient Side MVC & Angular
Client Side MVC & Angular
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key Features
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
AngularJS - Javascript framework for superheroes
AngularJS - Javascript framework for superheroesAngularJS - Javascript framework for superheroes
AngularJS - Javascript framework for superheroes
 
Angular JS - Javascript framework for superheroes
Angular JS - Javascript framework for superheroesAngular JS - Javascript framework for superheroes
Angular JS - Javascript framework for superheroes
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarIntroduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumar
 
Jinal desai .net
Jinal desai .netJinal desai .net
Jinal desai .net
 
Android chapter16-web-services
Android chapter16-web-servicesAndroid chapter16-web-services
Android chapter16-web-services
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
Angular.js interview questions
Angular.js interview questionsAngular.js interview questions
Angular.js interview questions
 
Unit 07: Design Patterns and Frameworks (1/3)
Unit 07: Design Patterns and Frameworks (1/3)Unit 07: Design Patterns and Frameworks (1/3)
Unit 07: Design Patterns and Frameworks (1/3)
 
MVC
MVCMVC
MVC
 
.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQ.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQ
 
MVC
MVCMVC
MVC
 
Single Page Application
Single Page ApplicationSingle Page Application
Single Page Application
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFramework
 
Modern webtechnologies
Modern webtechnologiesModern webtechnologies
Modern webtechnologies
 
Advanced web application architecture Way2Web
Advanced web application architecture Way2WebAdvanced web application architecture Way2Web
Advanced web application architecture Way2Web
 

Dernier

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 

Dernier (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 

Angularjs

  • 1. HTML enhanced for web apps!HTML enhanced for web apps!
  • 2. Back in time ... Websites instead of webapps Client seen as an interface All the workload handled by the server No client-side logic Javascript coder seen as web designer … when dinosaurs rule the Earth
  • 3. Getting into the present day... AJAX – HTML5 – CSS3 Web 2.0 Client splitted from server Lots of new Javascript libraries Webapp
  • 4. Javascript: the answer! Javascript frameworks MVC Architecture Big webapp No more comparison with web designers!
  • 5. A current problem Too much time Too much code Too much stress Building client-side webapp is still hard DOM Manipulation Data validation
  • 6. Angular for the life! Data-binding Basic templating directives Form validation Routing Reusable components Dependency injection Unit-testing
  • 7. Bootstrap Load HTML DOM Load the module associated with the directive Create the application injector Compile the DOM treating the ng- app directive as the root of the compilation
  • 8. Conceptual Overview 1. The browser loads the HTML and parses it into a DOM 2. The browser loads angular.js script 3. Angular waits for DOMContentLoaded event 4. Angular looks for ng-app directive, which designates the application boundary 5. The Module specified in ng-app (if any) is used to configure the $injector 6. The $injector is used to create the $compile service as well as $rootScope 7. The $compile service is used to compile the DOM and link it with $rootScope
  • 9. HTML Compiler Compile: traverse the DOM and collect all of the directives. The result is a linking function. Link: combine the directives with a scope and produce a live view. Any changes in the scope model are reflected in the view, and any user interactions with the view are reflected in the scope model. This makes the scope model the single source of truth. Compiler is an angular service which traverses the DOM looking for attributes
  • 11. Runtime 1. The browser's event-loop waits for an event to arrive. An event is a user interaction, timer event, or network event (response from a server) 2. The event's callback gets executed. This enters the JavaScript context. The callback can modify the DOM structure 3. Once the callback executes, the browser leaves the JavaScript context and re-renders the view based on DOM changes.
  • 12. Runtime in detail 1. Enter Angular execution context by calling scope. $apply(stimulusFn) 2. Angular executes the stimulusFn(), which typically modifies application state 3. Angular enters the $digest loop. The loop is made up of two smaller loops which process $evalAsync queue and the $watch list. The $digest loop keeps iterating until the model stabilizes. 4. The $evalAsync queue is used to schedule work which needs to occur outside of current stack frame, but before the browser's view render 5. The $watch list is a set of expressions which may have changed since last iteration. If a change is detected then the $watch function is called which typically updates the DOM with the new value 7. Once the Angular $digest loop finishes the execution leaves the Angular and JavaScript context. This is followed by the browser re- rendering the DOM to reflect any changes
  • 13. Scope & View The browser parses the HTML into the DOM, and the DOM becomes the input to the template engine known as the compiler. The compiler looks for directives which in turn set up watches on the model. The result is a continuously updating view which does not need template model re-merging. Your model becomes the single source- of-truth for your view. The scope is responsible for detecting changes to the model section and provides the execution context for expressions.
  • 14. Directives & Filters A directive is a behavior or DOM transformation which is triggered by the presence of a custom attribute, element name, or a class name. A directive allows you to extend the HTML vocabulary in a declarative fashion. <input type=”text” ng-model=”user.name” placeholder=”Foo”/> Filters perform data transformation. Typically they are used in conjunction with the locale to format the data in locale specific output. They follow the spirit of UNIX filters and use similar syntax | (pipe). <div>Negative number: {{val | number:2}}</div> <div>Your name (in lowercase): {{user.name | lowercase}}</div>
  • 15. Modules & Injectors The injector is a service locator. There is a single injector per Angular application. The injector provides a way to look up an object instance by its name. The injector keeps an internal cache of all objects so that repeated calls to get the same object name result in the same instance. If the object does not exist, then the injector asks the instance factory to create a new instance. A module is a way to configure the injector's instance factory, known as a provider.
  • 16. What's next? Forms i18n & l10n Modules Dependencies MVC E2E Testing Angular Services etc etc etc