SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
Explaination of Angular
John
Outline
● Overview
● Angular’s Work Flow
● Create Injector
● Binding Scope by RootScopeProvidor
● Compile Directive by CompileProvidor
● Summary
Overview
Separable of Logistic part and present part Extensible and Maintanable
Work Flow
Package to the one file, angular.js. In angularFiles.js, there declares many files
they will be merge into a file.
'angularSrc': [
...
'src/AngularPublic.js', 'src/jqLite.js', 'src/apis.js', 'src/auto/injector.js',
'src/angular.bind.js', 'src/publishExternalApis.js',
...
],
angular.js
Work Flow
Wrapping
angular.prefix
(function(window, document, undefined) {
angular.suffix
jqLite(document).ready(function() {
angularInit(document, bootstrap); // 3. Initialize
});
})(window, document);
angular.js
if (window.angular.bootstrap) {
return;
}
bindJQuery(); // 1. Binding JQuery
publishExternalAPI(angular); // 2. setupModuleLoader in loader.js
Work Flow
Flow Chart
Work Flow
Binding JQuery:
● Check whether includes JQuery (window.JQuery and JQuery element).
● Combine some functions of JQLite with JQuery.
● JQLite is a lite or tiny version of JQuery.
● If no loaded JQuery Angular will delegate to JQLite.
Work Flow
Setup modules:
● In this step, it declares Angular’s module.
● Within module instance, there are many
functions will execute pushing declaration into
a queue.
● While bootstrap, the declarations in the queue
will be invoked.
provider
service
factory
controller
invokeQueue
Work Flow
Setup modules:
● Then, setup the built-in module, ‘ng’.
● Ng module is dependended by ngLocale module.
● And setup most of built-in providers and most of directives
angularModule('ng', ['ngLocale'], ['$provide',
function ngModule($provide) {
// $$sanitizeUriProvider needs to be before $compileProvider as it is used by it.
$provide.provider({
$$sanitizeUri: $$SanitizeUriProvider
});
$provide.provider('$compile', $CompileProvider).
directive({
… //a lot of …...
});
}]);
Work Flow
Setup modules:
● So when you use Angular and define
your controller that will not be
invoked immediately.
● All of your definations are
invoked in bootstrap stage.
● So you are able to define your controller in different annotation, ‘array’ or
‘function’.
Work Flow
Angular initialization
● Call ‘angularInit’ function
● First, find out the element which has Angular app attribute. (ng-app/ng:app/...)
● Bootstrap the app element (Ex: <div ng-app />)
● If no app element Angular will not execute bootstrap.
● But we can bootstrap manually.
//Bootstrap the Angular application
angular.module('app', []);
angular.bootstrap(container, ['app']);
Work Flow
Angular initialization
● Angular’s Bootstrap ‘bootstrap’ function
● If a module has been loaded into the browser more than once it only allow the
first loaded script to be bootstrapped.
● At the initialization, the modules prepare to be bootstrapped would be like
['ng', [$provide, function($provide){...}], 'app']
○ ng: The built-in module
○ anonymous module: for setting app element to the $rootElement
○ application module
● Finally, create InjectorProvider, then use InjectorProvider to invoke compiling
directives in the DOMs within app element.
var injector = createInjector(modules, config.strictDi);
Create Injector
● While creating Injector, there are two caches, ProviderCache and
InstanceCache. And two injectors, ProviderInjector and InstanceInjector.
providerCache = {
$provide: { … }
},
providerInjector = (providerCache.$injector =
createInternalInjector(providerCache, function(serviceName, caller) {
if (angular.isString(caller)) { path.push(caller); }
throw $injectorMinErr('unpr', "Unknown provider: {0}", path.join(' <- '));
})),
instanceCache = {},
instanceInjector = (instanceCache.$injector =
createInternalInjector(instanceCache, function(serviceName, caller) {
var provider = providerInjector.get(serviceName + providerSuffix, caller);
return instanceInjector.invoke(provider.$get, provider, undefined, serviceName);
}));
Create Injector
● ProviderCache has a default member:
● ProviderInejctor and InstanceInjector are member, $injector, of
ProviderCache and InstanceCache.
$provide: {
provider: supportObject(provider),
factory: supportObject(factory),
service: supportObject(service),
value: supportObject(value),
constant: supportObject(constant),
decorator: decorator
}
Create Injector
● Injector is responsible for getting the service from the cache and invoking the
constructor function that will be put dependancies as parameter.
● After initiate two injectors, it will load and setup each module with Injectors
recursively. (function loadModules)
Create Injector
● In Initialization, there is a built-in module, ‘ng’, at the first element in the queue
is going to bootstrap and it must be ‘string’ type. That guarantee the ‘ng’
module to be invoked as first.
● The ‘ng’ module includes built-in services and built-in directives they will be
loaded in the cache (InstanceCache).
● If it can’t find an instance from InstanceCache it will get from ProviderCache
and invoke $get, finally save the instance to InstanceCache.
instanceInjector = (instanceCache.$injector =
createInternalInjector(instanceCache, function(serviceName, caller) {
var provider = providerInjector.get(serviceName + providerSuffix, caller);
return instanceInjector.invoke(provider.$get, provider, undefined, serviceName);
}));
Create Injector
Injectable class: They would be saved in the cache
provider.$get would be saved in InstanceCache
Binding Scope
● As Scope’s name, it is a field you can save data into it.
● Scope is like a tree node that can link to its parent, child, or sib.
● Scope contains some function to monitor and handle the data saving in
Scope.
Binding Scope
After creating injector InstanceInjector will be returned from function
‘createInjector’.
Then,
You can see it injects $rootScope and call $apply. What will it do?
injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector',
function bootstrapApply(scope, element, compile, injector) {
scope.$apply(function() {
element.data('$injector', injector);
compile(element)(scope);
});
}]
);
Binding Scope
● Actually, $apply can do that excutes
the expression (i.e,. {{x}} ) or function and
finally invokes $digest to scan the watchee.
● Every watchee is saved in a list, $$watchers.
with the listener.
● $digest executes to scan $$watchers
whether the watchee is changed the contains.
● While compiling, the data of a element that is
an expression it would be regarded as a
watchee and save in the watch list.
$apply: function(expr) {
try {
beginPhase('$apply');
try {
return this.$eval(expr);
} finally {
clearPhase();
}
} catch (e) {
$exceptionHandler(e);
} finally {
try {
$rootScope.$digest();
} catch (e) {
$exceptionHandler(e);
throw e;
}
}
}
Binding Scope
● From RootSope, we can use $new to create a child Scope.
● And access relative Scope by using $root, $parent, $childHead, $childTail,
$prevSibling, $nextSibling.
● Passing message within Tree Structure with broadcast and $emit.
Binding Scope
● Back to
● Here means invoking the function and using ‘compile’ service to compile root
element and bind with root scope.
● Next, going on explaining CompileProvider and its service.
injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector',
function bootstrapApply(scope, element, compile, injector) {
scope.$apply(function() {
element.data('$injector', injector);
compile(element)(scope);
});
}]
);
Compile Directive
● In Setup Modules, see the angularModule we can register a Directive with
‘directive’ function but do later in the bootstrap.
CompileProvider
register
this.directive =
function registerDirective(name, directiveFactory) {
...
}
Compile Directive
● $CompileProvider is a service provider and it’s
service instance is ‘compile’ will be returned
from $CompileProvider.$get.
function compile($compileNodes, transcludeFn, maxPriority,
ignoreDirective, previousCompileContext) {
...
var compositeLinkFn =
compileNodes($compileNodes, transcludeFn, $compileNodes,
maxPriority, ignoreDirective, previousCompileContext);
...
return function publicLinkFn(scope, cloneConnectFn, options) {
... };
}
Compile Directive
● In Binding Scope, you could see
element is $rootElement and scope is $rootScope.
● It injects ‘compile’ service and compile the root element then bind the root
scope.
● Inside ‘compile’, it compile all nodes include in the element past as parameter.
● First, collect all directive include in the root node of the element, the directive
may ‘E’(element) type, ‘A’(attribute) type, or ‘C’(class) type.
● Then, it recursively parsing child node of th element. Each run of parsing will
collect directives and apply template on directive.
● At the final, return a link function that is able to apply all nodes to bind with
Scopes duplicate from the past Scope.
compile(element)(scope);
Compile Directive
Example:
per each edge
From root recursively traverse
Summary
● First in initialization, declares Angular Module, then setup(load) built-in
module, ‘ng’ and its services, directive, factory, etc. And also setup(load)
application module.
● Create Injector that includes Caches to cache the instances. - Independency
Injection
● Second in bootstraping, initiates and injects relatived instances to loaded
module. - Inject services
● Then, compiling elements from given root element at the meanwhile collect all
directives and expressions. - Virtual DOM
● Final, binding the node with Scope. - Data binding

Weitere ähnliche Inhalte

Was ist angesagt?

Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptVisual Engineering
 
Async patterns in javascript
Async patterns in javascriptAsync patterns in javascript
Async patterns in javascriptRan Wahle
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJSRan Mizrahi
 
Property wrapper and how to use them with mvvm in swift ui i copy
Property wrapper and how to use them with mvvm in swift ui i copyProperty wrapper and how to use them with mvvm in swift ui i copy
Property wrapper and how to use them with mvvm in swift ui i copyWannitaTolaema
 
Building Robust jQuery Plugins
Building Robust jQuery PluginsBuilding Robust jQuery Plugins
Building Robust jQuery PluginsJörn Zaefferer
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-senseBen Lin
 
Workshop 25: React Native - Components
Workshop 25: React Native - ComponentsWorkshop 25: React Native - Components
Workshop 25: React Native - ComponentsVisual Engineering
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJSWei Ru
 
Angular - injection tokens & Custom libraries
Angular - injection tokens & Custom librariesAngular - injection tokens & Custom libraries
Angular - injection tokens & Custom librariesEliran Eliassy
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationEyal Vardi
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascriptDoeun KOCH
 
CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013Spyros Ioakeimidis
 
Workshop 24: React Native Introduction
Workshop 24: React Native IntroductionWorkshop 24: React Native Introduction
Workshop 24: React Native IntroductionVisual Engineering
 
Advanced JavaScript Concepts
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript ConceptsNaresh Kumar
 

Was ist angesagt? (20)

Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
 
Workshop 17: EmberJS parte II
Workshop 17: EmberJS parte IIWorkshop 17: EmberJS parte II
Workshop 17: EmberJS parte II
 
Async patterns in javascript
Async patterns in javascriptAsync patterns in javascript
Async patterns in javascript
 
AngularJS.part1
AngularJS.part1AngularJS.part1
AngularJS.part1
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJS
 
Solid angular
Solid angularSolid angular
Solid angular
 
Property wrapper and how to use them with mvvm in swift ui i copy
Property wrapper and how to use them with mvvm in swift ui i copyProperty wrapper and how to use them with mvvm in swift ui i copy
Property wrapper and how to use them with mvvm in swift ui i copy
 
AngularJS - TechTalk 3/2/2014
AngularJS - TechTalk 3/2/2014AngularJS - TechTalk 3/2/2014
AngularJS - TechTalk 3/2/2014
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
Building Robust jQuery Plugins
Building Robust jQuery PluginsBuilding Robust jQuery Plugins
Building Robust jQuery Plugins
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-sense
 
Ngrx meta reducers
Ngrx meta reducersNgrx meta reducers
Ngrx meta reducers
 
Workshop 25: React Native - Components
Workshop 25: React Native - ComponentsWorkshop 25: React Native - Components
Workshop 25: React Native - Components
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
Angular - injection tokens & Custom libraries
Angular - injection tokens & Custom librariesAngular - injection tokens & Custom libraries
Angular - injection tokens & Custom libraries
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
 
CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013
 
Workshop 24: React Native Introduction
Workshop 24: React Native IntroductionWorkshop 24: React Native Introduction
Workshop 24: React Native Introduction
 
Advanced JavaScript Concepts
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript Concepts
 

Ähnlich wie Explaination of angular

Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIVisual Engineering
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JSBipin
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIVisual Engineering
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS ArchitectureEyal Vardi
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS BasicsRavi Mone
 
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xAngular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xEyal Vardi
 
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0Frost
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionDzmitry Ivashutsin
 
Top 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers MakeTop 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers MakeMark Meyer
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development GuideNitin Giri
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJSRajthilakMCA
 
AngularJS - Services
AngularJS - ServicesAngularJS - Services
AngularJS - ServicesNir Kaufman
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications Juliana Lucena
 
Integrating Angular js & three.js
Integrating Angular js & three.jsIntegrating Angular js & three.js
Integrating Angular js & three.jsJosh Staples
 

Ähnlich wie Explaination of angular (20)

Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
 
Angular js
Angular jsAngular js
Angular js
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
 
Angular 2 in-1
Angular 2 in-1 Angular 2 in-1
Angular 2 in-1
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte III
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xAngular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.x
 
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
 
AngularJs-training
AngularJs-trainingAngularJs-training
AngularJs-training
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency Injection
 
Top 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers MakeTop 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers Make
 
Angular IO
Angular IOAngular IO
Angular IO
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
 
AngularJS - Services
AngularJS - ServicesAngularJS - Services
AngularJS - Services
 
Simple React Todo List
Simple React Todo ListSimple React Todo List
Simple React Todo List
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications
 
Integrating Angular js & three.js
Integrating Angular js & three.jsIntegrating Angular js & three.js
Integrating Angular js & three.js
 

Mehr von Kan-Han (John) Lu

Working process and git branch strategy
Working process and git branch strategyWorking process and git branch strategy
Working process and git branch strategyKan-Han (John) Lu
 
Deep neural network for youtube recommendations
Deep neural network for youtube recommendationsDeep neural network for youtube recommendations
Deep neural network for youtube recommendationsKan-Han (John) Lu
 
Twitter as a personalizable information service ii
Twitter as a personalizable information service iiTwitter as a personalizable information service ii
Twitter as a personalizable information service iiKan-Han (John) Lu
 
Multimedia data minig and analytics sentiment analysis using social multimedia
Multimedia data minig and analytics sentiment analysis using social multimediaMultimedia data minig and analytics sentiment analysis using social multimedia
Multimedia data minig and analytics sentiment analysis using social multimediaKan-Han (John) Lu
 
ARM: Trusted Zone on Android
ARM: Trusted Zone on AndroidARM: Trusted Zone on Android
ARM: Trusted Zone on AndroidKan-Han (John) Lu
 
Android Training - Card Style
Android Training - Card StyleAndroid Training - Card Style
Android Training - Card StyleKan-Han (John) Lu
 
Android Training - View Pager
Android Training - View PagerAndroid Training - View Pager
Android Training - View PagerKan-Han (John) Lu
 
Android Training - Sliding Menu
Android Training - Sliding MenuAndroid Training - Sliding Menu
Android Training - Sliding MenuKan-Han (John) Lu
 
Android Training - Pull to Refresh
Android Training - Pull to RefreshAndroid Training - Pull to Refresh
Android Training - Pull to RefreshKan-Han (John) Lu
 
Code analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMDCode analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMDKan-Han (John) Lu
 
Android Training - Content Sharing
Android Training - Content SharingAndroid Training - Content Sharing
Android Training - Content SharingKan-Han (John) Lu
 

Mehr von Kan-Han (John) Lu (20)

Dagger for android
Dagger for androidDagger for android
Dagger for android
 
Android develop guideline
Android develop guidelineAndroid develop guideline
Android develop guideline
 
Working process and git branch strategy
Working process and git branch strategyWorking process and git branch strategy
Working process and git branch strategy
 
Deep neural network for youtube recommendations
Deep neural network for youtube recommendationsDeep neural network for youtube recommendations
Deep neural network for youtube recommendations
 
Android testing part i
Android testing part iAndroid testing part i
Android testing part i
 
Cuda project paper
Cuda project paperCuda project paper
Cuda project paper
 
Twitter as a personalizable information service ii
Twitter as a personalizable information service iiTwitter as a personalizable information service ii
Twitter as a personalizable information service ii
 
Multimedia data minig and analytics sentiment analysis using social multimedia
Multimedia data minig and analytics sentiment analysis using social multimediaMultimedia data minig and analytics sentiment analysis using social multimedia
Multimedia data minig and analytics sentiment analysis using social multimedia
 
Android IPC: Binder
Android IPC: BinderAndroid IPC: Binder
Android IPC: Binder
 
ARM: Trusted Zone on Android
ARM: Trusted Zone on AndroidARM: Trusted Zone on Android
ARM: Trusted Zone on Android
 
Android Training - Card Style
Android Training - Card StyleAndroid Training - Card Style
Android Training - Card Style
 
Android Training - View Pager
Android Training - View PagerAndroid Training - View Pager
Android Training - View Pager
 
Android Training - Sliding Menu
Android Training - Sliding MenuAndroid Training - Sliding Menu
Android Training - Sliding Menu
 
Android Training - Pull to Refresh
Android Training - Pull to RefreshAndroid Training - Pull to Refresh
Android Training - Pull to Refresh
 
Java: Exception Handling
Java: Exception HandlingJava: Exception Handling
Java: Exception Handling
 
Dynamic Proxy by Java
Dynamic Proxy by JavaDynamic Proxy by Java
Dynamic Proxy by Java
 
Code analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMDCode analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMD
 
Android UI System
Android UI SystemAndroid UI System
Android UI System
 
Android Fragment
Android FragmentAndroid Fragment
Android Fragment
 
Android Training - Content Sharing
Android Training - Content SharingAndroid Training - Content Sharing
Android Training - Content Sharing
 

Kürzlich hochgeladen

Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 

Kürzlich hochgeladen (20)

Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 

Explaination of angular

  • 2. Outline ● Overview ● Angular’s Work Flow ● Create Injector ● Binding Scope by RootScopeProvidor ● Compile Directive by CompileProvidor ● Summary
  • 3. Overview Separable of Logistic part and present part Extensible and Maintanable
  • 4. Work Flow Package to the one file, angular.js. In angularFiles.js, there declares many files they will be merge into a file. 'angularSrc': [ ... 'src/AngularPublic.js', 'src/jqLite.js', 'src/apis.js', 'src/auto/injector.js', 'src/angular.bind.js', 'src/publishExternalApis.js', ... ], angular.js
  • 5. Work Flow Wrapping angular.prefix (function(window, document, undefined) { angular.suffix jqLite(document).ready(function() { angularInit(document, bootstrap); // 3. Initialize }); })(window, document); angular.js if (window.angular.bootstrap) { return; } bindJQuery(); // 1. Binding JQuery publishExternalAPI(angular); // 2. setupModuleLoader in loader.js
  • 7. Work Flow Binding JQuery: ● Check whether includes JQuery (window.JQuery and JQuery element). ● Combine some functions of JQLite with JQuery. ● JQLite is a lite or tiny version of JQuery. ● If no loaded JQuery Angular will delegate to JQLite.
  • 8. Work Flow Setup modules: ● In this step, it declares Angular’s module. ● Within module instance, there are many functions will execute pushing declaration into a queue. ● While bootstrap, the declarations in the queue will be invoked. provider service factory controller invokeQueue
  • 9. Work Flow Setup modules: ● Then, setup the built-in module, ‘ng’. ● Ng module is dependended by ngLocale module. ● And setup most of built-in providers and most of directives angularModule('ng', ['ngLocale'], ['$provide', function ngModule($provide) { // $$sanitizeUriProvider needs to be before $compileProvider as it is used by it. $provide.provider({ $$sanitizeUri: $$SanitizeUriProvider }); $provide.provider('$compile', $CompileProvider). directive({ … //a lot of …... }); }]);
  • 10. Work Flow Setup modules: ● So when you use Angular and define your controller that will not be invoked immediately. ● All of your definations are invoked in bootstrap stage. ● So you are able to define your controller in different annotation, ‘array’ or ‘function’.
  • 11. Work Flow Angular initialization ● Call ‘angularInit’ function ● First, find out the element which has Angular app attribute. (ng-app/ng:app/...) ● Bootstrap the app element (Ex: <div ng-app />) ● If no app element Angular will not execute bootstrap. ● But we can bootstrap manually. //Bootstrap the Angular application angular.module('app', []); angular.bootstrap(container, ['app']);
  • 12. Work Flow Angular initialization ● Angular’s Bootstrap ‘bootstrap’ function ● If a module has been loaded into the browser more than once it only allow the first loaded script to be bootstrapped. ● At the initialization, the modules prepare to be bootstrapped would be like ['ng', [$provide, function($provide){...}], 'app'] ○ ng: The built-in module ○ anonymous module: for setting app element to the $rootElement ○ application module ● Finally, create InjectorProvider, then use InjectorProvider to invoke compiling directives in the DOMs within app element. var injector = createInjector(modules, config.strictDi);
  • 13. Create Injector ● While creating Injector, there are two caches, ProviderCache and InstanceCache. And two injectors, ProviderInjector and InstanceInjector. providerCache = { $provide: { … } }, providerInjector = (providerCache.$injector = createInternalInjector(providerCache, function(serviceName, caller) { if (angular.isString(caller)) { path.push(caller); } throw $injectorMinErr('unpr', "Unknown provider: {0}", path.join(' <- ')); })), instanceCache = {}, instanceInjector = (instanceCache.$injector = createInternalInjector(instanceCache, function(serviceName, caller) { var provider = providerInjector.get(serviceName + providerSuffix, caller); return instanceInjector.invoke(provider.$get, provider, undefined, serviceName); }));
  • 14. Create Injector ● ProviderCache has a default member: ● ProviderInejctor and InstanceInjector are member, $injector, of ProviderCache and InstanceCache. $provide: { provider: supportObject(provider), factory: supportObject(factory), service: supportObject(service), value: supportObject(value), constant: supportObject(constant), decorator: decorator }
  • 15. Create Injector ● Injector is responsible for getting the service from the cache and invoking the constructor function that will be put dependancies as parameter. ● After initiate two injectors, it will load and setup each module with Injectors recursively. (function loadModules)
  • 16. Create Injector ● In Initialization, there is a built-in module, ‘ng’, at the first element in the queue is going to bootstrap and it must be ‘string’ type. That guarantee the ‘ng’ module to be invoked as first. ● The ‘ng’ module includes built-in services and built-in directives they will be loaded in the cache (InstanceCache). ● If it can’t find an instance from InstanceCache it will get from ProviderCache and invoke $get, finally save the instance to InstanceCache. instanceInjector = (instanceCache.$injector = createInternalInjector(instanceCache, function(serviceName, caller) { var provider = providerInjector.get(serviceName + providerSuffix, caller); return instanceInjector.invoke(provider.$get, provider, undefined, serviceName); }));
  • 17. Create Injector Injectable class: They would be saved in the cache provider.$get would be saved in InstanceCache
  • 18. Binding Scope ● As Scope’s name, it is a field you can save data into it. ● Scope is like a tree node that can link to its parent, child, or sib. ● Scope contains some function to monitor and handle the data saving in Scope.
  • 19. Binding Scope After creating injector InstanceInjector will be returned from function ‘createInjector’. Then, You can see it injects $rootScope and call $apply. What will it do? injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector', function bootstrapApply(scope, element, compile, injector) { scope.$apply(function() { element.data('$injector', injector); compile(element)(scope); }); }] );
  • 20. Binding Scope ● Actually, $apply can do that excutes the expression (i.e,. {{x}} ) or function and finally invokes $digest to scan the watchee. ● Every watchee is saved in a list, $$watchers. with the listener. ● $digest executes to scan $$watchers whether the watchee is changed the contains. ● While compiling, the data of a element that is an expression it would be regarded as a watchee and save in the watch list. $apply: function(expr) { try { beginPhase('$apply'); try { return this.$eval(expr); } finally { clearPhase(); } } catch (e) { $exceptionHandler(e); } finally { try { $rootScope.$digest(); } catch (e) { $exceptionHandler(e); throw e; } } }
  • 21. Binding Scope ● From RootSope, we can use $new to create a child Scope. ● And access relative Scope by using $root, $parent, $childHead, $childTail, $prevSibling, $nextSibling. ● Passing message within Tree Structure with broadcast and $emit.
  • 22. Binding Scope ● Back to ● Here means invoking the function and using ‘compile’ service to compile root element and bind with root scope. ● Next, going on explaining CompileProvider and its service. injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector', function bootstrapApply(scope, element, compile, injector) { scope.$apply(function() { element.data('$injector', injector); compile(element)(scope); }); }] );
  • 23. Compile Directive ● In Setup Modules, see the angularModule we can register a Directive with ‘directive’ function but do later in the bootstrap. CompileProvider register this.directive = function registerDirective(name, directiveFactory) { ... }
  • 24. Compile Directive ● $CompileProvider is a service provider and it’s service instance is ‘compile’ will be returned from $CompileProvider.$get. function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, previousCompileContext) { ... var compositeLinkFn = compileNodes($compileNodes, transcludeFn, $compileNodes, maxPriority, ignoreDirective, previousCompileContext); ... return function publicLinkFn(scope, cloneConnectFn, options) { ... }; }
  • 25. Compile Directive ● In Binding Scope, you could see element is $rootElement and scope is $rootScope. ● It injects ‘compile’ service and compile the root element then bind the root scope. ● Inside ‘compile’, it compile all nodes include in the element past as parameter. ● First, collect all directive include in the root node of the element, the directive may ‘E’(element) type, ‘A’(attribute) type, or ‘C’(class) type. ● Then, it recursively parsing child node of th element. Each run of parsing will collect directives and apply template on directive. ● At the final, return a link function that is able to apply all nodes to bind with Scopes duplicate from the past Scope. compile(element)(scope);
  • 26. Compile Directive Example: per each edge From root recursively traverse
  • 27. Summary ● First in initialization, declares Angular Module, then setup(load) built-in module, ‘ng’ and its services, directive, factory, etc. And also setup(load) application module. ● Create Injector that includes Caches to cache the instances. - Independency Injection ● Second in bootstraping, initiates and injects relatived instances to loaded module. - Inject services ● Then, compiling elements from given root element at the meanwhile collect all directives and expressions. - Virtual DOM ● Final, binding the node with Scope. - Data binding