SlideShare a Scribd company logo
Modules and injector
angular
Modules (private)
angular.module( 'moduleName' , [ ] ) angular.module( 'moduleName' )
moduleName
<html lang="en" ng-app="myTodo">
<body>
...
<script src="lib/angular.js"></script>
<!-- My Modules -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
</body>
</html>
// app.js file must to be first
angular.module('myTodo',[]);
// controllers.js must to be after app.js
angular.module('myTodo');
angular.module('myApp', ['bl'])
// Name (key) and value (function)
.controller('MainCtrl',MainCtrl)
.directive ('tabs',tabsDirective)
.provider('proxy',proxyProvider)
// Functions only
.config(function(proxyProvider){…})
.run(function(proxy){…});
 name : 'myApp'
 requires : [ 'bl']
_runBlocks : [ ]
_configBlocks : [ ]
_invokeQueue : [ ]
'MainCtrl',MainCtrl
'tabs',tabsDirective
'proxy',proxyProvider
function(proxyProvider){…}
function(proxy){…}
 name : string
 requires : [ ]
_runBlocks : [ ]
run( initializationFn )
_configBlocks : [ ]
Config(function( xxxProvider ){ })
_invokeQueue : [ ]
- controller(name, constructor)
- directive (name, directiveFn)
- filter (name, filterFactory)
- animation (name, animationFactory)
- service (name, constructor)
- factory (name, providerFn)
- provider (name, providerType)
- decorator(name, fn )
- constant (name, object)
- value (name, object)
angular
Modules (private)
Browser
<html lang="en" ng-app="app">
<body>
<div class="view-container">
<div ng-view class="view-frame"></div>
</div>
<script src="lib/angular.js"></script>
<!-- Angular Modules -->
<script src="lib/angular-route.js"></script>
<!-- My Modules -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
</body>
</html>
ngRoute app
ctrls services
DOM Content
Loaded Event
Modules and injector
var injector = createInjector(modules);
injector.invoke([
'$rootScope','$rootElement','$compile','$injector','$animate',
function(scope, element, compile, injector, animate) {
scope.$apply(function() {
element.data('$injector', injector);
compile(element)(scope);
});
}]
);
Create the injector and
load the modules to
the injector.
Compile the root
element and return
link function.
Execute the link
function with the root
scope.
Apply,
update
the page
angular
Modules (private)
ngRoute app
ctrls services
$injector (Instance Injector)
Provider Injector
Instance Cache
Provider Cache
Keys Values
Invoke( )get( )
Keys Values
instantiate( ) has( )
Invoke( )get( ) instantiate( ) has( )
angular
Modules (private)
ngRoute
app
ctrls
services
<!-- app.js -->
angular.module('app',['ngRoute','ctrls'])
.config(function($routeProvider){});
<!-- angular-route.js -->
angular.module('ngRoute',[])
.provider('$route',fn);
<!-- controllers.js -->
angular.module('ctrls',['services'])
.controller('MainCtrl', fn);
<!-- services.js -->
angular.module('services',[])
.service('todoSer', fn);
<html lang="en" ng-app="app">
angular
Modules (private)
ngRoute
app
services
Provider Injector
Keys Values
todoSer
{ $get : factoryFn }
$controllerProvider
Keys Values
constructor
$route
{ $get : factoryFn }
config
ctrls
MainCtrl
{ $get : factoryFn }
todoSer
Provider
$route
Provider
angular
$injector
Provider Injector
Instance Cache
Provider Cache
Keys Values
{ $get : factoryFn }
{ $get : factoryFn }
todoSerProvider
$routeProvider
Invoke( )get( )
Keys Values
instantiate( ) has( )
Invoke( )get( ) instantiate( ) has( )
angular
Provider Injector
Instance Cache
Provider Cache
Keys Values
{ $get : factoryFn }
{ $get : factoryFn }
todoSerProvider
$routeProvider
angular.module('app',['ngRoute','ctrls']
.run(function runFn(todoSer){ todoSer.load(); });
Invoke( runFn )get( 'todoSer' )
get( 'todoSer' + 'Provider' )
Keys Values
{ . . .}todoSer
ngXXX
angular.module('myApp', ['ngXXX', 'ngYYY']);
Invoke
Queue
ngYYY
Invoke
Queue
myApp
Invoke
Queue
Config
blocks
Config
blocks
Config
blocks
Run
blocks
Run
blocks
Run
blocks
$injector
Instance
Cache
Provider
Cache
// You write functions such as this one.
function doSomething(serviceA, serviceB) {
// do something here.
}
// Angular provides the injector for your application
var $injector = ...;
$injector.invoke(doSomething);
var serviceA = $injector.get('serviceA');
var serviceB = $injector.get('serviceB');
doSomething(serviceA, serviceB);
// inline option
$injector.invoke( [ 'serviceA', function (serviceA) { } ] );
$injector.invoke( function (serviceA) { } );
$injector.invoke( function ( sa ) { } );
minified
xxx.js
xxx.min.js
// annotated option
explicit.$inject = ['serviceA'];
function explicit(serviceA) { };
$injector.invoke(explicit);
<ANY ng-app="angular.Module" [ng-strict-di="boolean"]>
...
</ANY>
Useful for debugging info, will assist in
tracking down the root of these bugs.
<html lang="en" ng-app="app">
<body>
<script src="lib/angular.js"></script>
<script src="lib/angular-route.js"></script>
<script src="js/app.js"></script>
</body>
</html>
angular.module('app', ['ngRoute']);
The module file are
being downloaded
correctly
The module name
in the requires is
not misspelled
<html lang="en" ng-app="app">
<body ng-controller="Ctrl">
<script src="angular.js"></script>
<script src="angular-route.js"></script>
<script src="app.js"></script>
</body>
</html>
angular.module('app', ['ngRoute']).controller('Ctrl', function(){...});
The module, where
the provider /
controller is
defined, is loaded
to the injector
Spelled
correctly
Modules and injector
HTML
Browser
Static
DOM
Dynamic
DOM
(View)
AngularJS
DOM
Content
Loaded
Event
ng-app=“module”
$injector
$compile $rootScope
$compile (dom,
$rootScope)
Ad

More Related Content

What's hot (20)

Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0
Eyal Vardi
 
AngularJS $Provide Service
AngularJS $Provide ServiceAngularJS $Provide Service
AngularJS $Provide Service
Eyal Vardi
 
Databinding and Performance-Tuning in Angular 2
Databinding and Performance-Tuning in Angular 2Databinding and Performance-Tuning in Angular 2
Databinding and Performance-Tuning in Angular 2
Manfred Steyer
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
Eyal Vardi
 
Angular 2.0 Dependency injection
Angular 2.0 Dependency injectionAngular 2.0 Dependency injection
Angular 2.0 Dependency injection
Eyal Vardi
 
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
Eyal Vardi
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
Eyal Vardi
 
Angular 2 Architecture
Angular 2 ArchitectureAngular 2 Architecture
Angular 2 Architecture
Eyal Vardi
 
AngularJs $provide API internals & circular dependency problem.
AngularJs $provide API internals & circular dependency problem.AngularJs $provide API internals & circular dependency problem.
AngularJs $provide API internals & circular dependency problem.
Yan Yankowski
 
Angular 2 NgModule
Angular 2 NgModuleAngular 2 NgModule
Angular 2 NgModule
Eyal Vardi
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS Directives
Eyal Vardi
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
Eyal Vardi
 
Angular js routing options
Angular js routing optionsAngular js routing options
Angular js routing options
Nir Kaufman
 
AngularJs
AngularJsAngularJs
AngularJs
syam kumar kk
 
AngularJS Framework
AngularJS FrameworkAngularJS Framework
AngularJS Framework
Barcamp Saigon
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
Sergey Bolshchikov
 
Building an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationBuilding an End-to-End AngularJS Application
Building an End-to-End AngularJS Application
Dan Wahlin
 
AngularJS Services
AngularJS ServicesAngularJS Services
AngularJS Services
Eyal Vardi
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
Wei Ru
 
준비하세요 Angular js 2.0
준비하세요 Angular js 2.0준비하세요 Angular js 2.0
준비하세요 Angular js 2.0
Jeado Ko
 
Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0
Eyal Vardi
 
AngularJS $Provide Service
AngularJS $Provide ServiceAngularJS $Provide Service
AngularJS $Provide Service
Eyal Vardi
 
Databinding and Performance-Tuning in Angular 2
Databinding and Performance-Tuning in Angular 2Databinding and Performance-Tuning in Angular 2
Databinding and Performance-Tuning in Angular 2
Manfred Steyer
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
Eyal Vardi
 
Angular 2.0 Dependency injection
Angular 2.0 Dependency injectionAngular 2.0 Dependency injection
Angular 2.0 Dependency injection
Eyal Vardi
 
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
Eyal Vardi
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
Eyal Vardi
 
Angular 2 Architecture
Angular 2 ArchitectureAngular 2 Architecture
Angular 2 Architecture
Eyal Vardi
 
AngularJs $provide API internals & circular dependency problem.
AngularJs $provide API internals & circular dependency problem.AngularJs $provide API internals & circular dependency problem.
AngularJs $provide API internals & circular dependency problem.
Yan Yankowski
 
Angular 2 NgModule
Angular 2 NgModuleAngular 2 NgModule
Angular 2 NgModule
Eyal Vardi
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS Directives
Eyal Vardi
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
Eyal Vardi
 
Angular js routing options
Angular js routing optionsAngular js routing options
Angular js routing options
Nir Kaufman
 
Building an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationBuilding an End-to-End AngularJS Application
Building an End-to-End AngularJS Application
Dan Wahlin
 
AngularJS Services
AngularJS ServicesAngularJS Services
AngularJS Services
Eyal Vardi
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
Wei Ru
 
준비하세요 Angular js 2.0
준비하세요 Angular js 2.0준비하세요 Angular js 2.0
준비하세요 Angular js 2.0
Jeado Ko
 

Viewers also liked (17)

Node.js File system & Streams
Node.js File system & StreamsNode.js File system & Streams
Node.js File system & Streams
Eyal Vardi
 
Node.js Socket.IO
Node.js  Socket.IONode.js  Socket.IO
Node.js Socket.IO
Eyal Vardi
 
Node js overview
Node js overviewNode js overview
Node js overview
Eyal Vardi
 
Node.js Event Emitter
Node.js Event EmitterNode.js Event Emitter
Node.js Event Emitter
Eyal Vardi
 
Async & Parallel in JavaScript
Async & Parallel in JavaScriptAsync & Parallel in JavaScript
Async & Parallel in JavaScript
Eyal Vardi
 
Angular 2.0 Views
Angular 2.0 ViewsAngular 2.0 Views
Angular 2.0 Views
Eyal Vardi
 
Angular 2.0 Pipes
Angular 2.0 PipesAngular 2.0 Pipes
Angular 2.0 Pipes
Eyal Vardi
 
Nodejs
NodejsNodejs
Nodejs
Eyal Vardi
 
Node.js Spplication Scaling
Node.js Spplication ScalingNode.js Spplication Scaling
Node.js Spplication Scaling
Eyal Vardi
 
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
Eyal Vardi
 
Modules in ECMAScript 6.0
Modules in ECMAScript 6.0Modules in ECMAScript 6.0
Modules in ECMAScript 6.0
Eyal Vardi
 
AngularJS Routing
AngularJS RoutingAngularJS Routing
AngularJS Routing
Eyal Vardi
 
Making use of OpenStreetMap data with Python
Making use of OpenStreetMap data with PythonMaking use of OpenStreetMap data with Python
Making use of OpenStreetMap data with Python
Andrii Mishkovskyi
 
Rachel's grandmother's recipes
Rachel's grandmother's recipesRachel's grandmother's recipes
Rachel's grandmother's recipes
Eyal Vardi
 
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
Allen Wirfs-Brock
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
hesher
 
OpenStreetMap in 3D using Python
OpenStreetMap in 3D using PythonOpenStreetMap in 3D using Python
OpenStreetMap in 3D using Python
Martin Christen
 
Node.js File system & Streams
Node.js File system & StreamsNode.js File system & Streams
Node.js File system & Streams
Eyal Vardi
 
Node.js Socket.IO
Node.js  Socket.IONode.js  Socket.IO
Node.js Socket.IO
Eyal Vardi
 
Node js overview
Node js overviewNode js overview
Node js overview
Eyal Vardi
 
Node.js Event Emitter
Node.js Event EmitterNode.js Event Emitter
Node.js Event Emitter
Eyal Vardi
 
Async & Parallel in JavaScript
Async & Parallel in JavaScriptAsync & Parallel in JavaScript
Async & Parallel in JavaScript
Eyal Vardi
 
Angular 2.0 Views
Angular 2.0 ViewsAngular 2.0 Views
Angular 2.0 Views
Eyal Vardi
 
Angular 2.0 Pipes
Angular 2.0 PipesAngular 2.0 Pipes
Angular 2.0 Pipes
Eyal Vardi
 
Node.js Spplication Scaling
Node.js Spplication ScalingNode.js Spplication Scaling
Node.js Spplication Scaling
Eyal Vardi
 
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
Eyal Vardi
 
Modules in ECMAScript 6.0
Modules in ECMAScript 6.0Modules in ECMAScript 6.0
Modules in ECMAScript 6.0
Eyal Vardi
 
AngularJS Routing
AngularJS RoutingAngularJS Routing
AngularJS Routing
Eyal Vardi
 
Making use of OpenStreetMap data with Python
Making use of OpenStreetMap data with PythonMaking use of OpenStreetMap data with Python
Making use of OpenStreetMap data with Python
Andrii Mishkovskyi
 
Rachel's grandmother's recipes
Rachel's grandmother's recipesRachel's grandmother's recipes
Rachel's grandmother's recipes
Eyal Vardi
 
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
Allen Wirfs-Brock
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
hesher
 
OpenStreetMap in 3D using Python
OpenStreetMap in 3D using PythonOpenStreetMap in 3D using Python
OpenStreetMap in 3D using Python
Martin Christen
 
Ad

Similar to Modules and injector (20)

"Angular.js Concepts in Depth" by Aleksandar Simović
"Angular.js Concepts in Depth" by Aleksandar Simović"Angular.js Concepts in Depth" by Aleksandar Simović
"Angular.js Concepts in Depth" by Aleksandar Simović
JS Belgrade
 
Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2
Christoffer Noring
 
AngularJs
AngularJsAngularJs
AngularJs
Hossein Baghayi
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
Christoffer Noring
 
Opinionated AngularJS
Opinionated AngularJSOpinionated AngularJS
Opinionated AngularJS
prabhutech
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
Ryunosuke SATO
 
Protractor framework architecture with example
Protractor framework architecture with exampleProtractor framework architecture with example
Protractor framework architecture with example
shadabgilani
 
Technozaure - Angular2
Technozaure - Angular2Technozaure - Angular2
Technozaure - Angular2
Demey Emmanuel
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
Jonathan Wage
 
Angular2 - In Action
Angular2  - In ActionAngular2  - In Action
Angular2 - In Action
Sebastian Pożoga
 
A Story about AngularJS modularization development
A Story about AngularJS modularization developmentA Story about AngularJS modularization development
A Story about AngularJS modularization development
Johannes Weber
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
Lukas Smith
 
AngularJs-training
AngularJs-trainingAngularJs-training
AngularJs-training
Pratchaya Suputsopon
 
We sport architecture_implementation
We sport architecture_implementationWe sport architecture_implementation
We sport architecture_implementation
aurelianaur
 
Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1
Ahmed Moawad
 
ChtiJUG - Introduction à Angular2
ChtiJUG - Introduction à Angular2ChtiJUG - Introduction à Angular2
ChtiJUG - Introduction à Angular2
Demey Emmanuel
 
Top 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers MakeTop 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers Make
Mark Meyer
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점 Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
WebFrameworks
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Jeado Ko
 
Angular js
Angular jsAngular js
Angular js
Behind D Walls
 
"Angular.js Concepts in Depth" by Aleksandar Simović
"Angular.js Concepts in Depth" by Aleksandar Simović"Angular.js Concepts in Depth" by Aleksandar Simović
"Angular.js Concepts in Depth" by Aleksandar Simović
JS Belgrade
 
Opinionated AngularJS
Opinionated AngularJSOpinionated AngularJS
Opinionated AngularJS
prabhutech
 
Protractor framework architecture with example
Protractor framework architecture with exampleProtractor framework architecture with example
Protractor framework architecture with example
shadabgilani
 
Technozaure - Angular2
Technozaure - Angular2Technozaure - Angular2
Technozaure - Angular2
Demey Emmanuel
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
Jonathan Wage
 
A Story about AngularJS modularization development
A Story about AngularJS modularization developmentA Story about AngularJS modularization development
A Story about AngularJS modularization development
Johannes Weber
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
Lukas Smith
 
We sport architecture_implementation
We sport architecture_implementationWe sport architecture_implementation
We sport architecture_implementation
aurelianaur
 
Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1
Ahmed Moawad
 
ChtiJUG - Introduction à Angular2
ChtiJUG - Introduction à Angular2ChtiJUG - Introduction à Angular2
ChtiJUG - Introduction à Angular2
Demey Emmanuel
 
Top 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers MakeTop 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers Make
Mark Meyer
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점 Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
WebFrameworks
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Jeado Ko
 
Ad

More from Eyal Vardi (8)

Why magic
Why magicWhy magic
Why magic
Eyal Vardi
 
Smart Contract
Smart ContractSmart Contract
Smart Contract
Eyal Vardi
 
Proxies in ECMAScript 6.0
Proxies in ECMAScript 6.0Proxies in ECMAScript 6.0
Proxies in ECMAScript 6.0
Eyal Vardi
 
Iterators & Generators in ECMAScript 6.0
Iterators & Generators in ECMAScript 6.0Iterators & Generators in ECMAScript 6.0
Iterators & Generators in ECMAScript 6.0
Eyal Vardi
 
Symbols in ECMAScript 6.0
Symbols in ECMAScript 6.0Symbols in ECMAScript 6.0
Symbols in ECMAScript 6.0
Eyal Vardi
 
Objects & Classes in ECMAScript 6.0
Objects & Classes in ECMAScript 6.0Objects & Classes in ECMAScript 6.0
Objects & Classes in ECMAScript 6.0
Eyal Vardi
 
Scope & Functions in ECMAScript 6.0
Scope & Functions in ECMAScript 6.0Scope & Functions in ECMAScript 6.0
Scope & Functions in ECMAScript 6.0
Eyal Vardi
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
Eyal Vardi
 
Smart Contract
Smart ContractSmart Contract
Smart Contract
Eyal Vardi
 
Proxies in ECMAScript 6.0
Proxies in ECMAScript 6.0Proxies in ECMAScript 6.0
Proxies in ECMAScript 6.0
Eyal Vardi
 
Iterators & Generators in ECMAScript 6.0
Iterators & Generators in ECMAScript 6.0Iterators & Generators in ECMAScript 6.0
Iterators & Generators in ECMAScript 6.0
Eyal Vardi
 
Symbols in ECMAScript 6.0
Symbols in ECMAScript 6.0Symbols in ECMAScript 6.0
Symbols in ECMAScript 6.0
Eyal Vardi
 
Objects & Classes in ECMAScript 6.0
Objects & Classes in ECMAScript 6.0Objects & Classes in ECMAScript 6.0
Objects & Classes in ECMAScript 6.0
Eyal Vardi
 
Scope & Functions in ECMAScript 6.0
Scope & Functions in ECMAScript 6.0Scope & Functions in ECMAScript 6.0
Scope & Functions in ECMAScript 6.0
Eyal Vardi
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
Eyal Vardi
 

Recently uploaded (20)

Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 

Modules and injector

  • 2. angular Modules (private) angular.module( 'moduleName' , [ ] ) angular.module( 'moduleName' ) moduleName
  • 3. <html lang="en" ng-app="myTodo"> <body> ... <script src="lib/angular.js"></script> <!-- My Modules --> <script src="js/app.js"></script> <script src="js/controllers.js"></script> </body> </html> // app.js file must to be first angular.module('myTodo',[]); // controllers.js must to be after app.js angular.module('myTodo');
  • 4. angular.module('myApp', ['bl']) // Name (key) and value (function) .controller('MainCtrl',MainCtrl) .directive ('tabs',tabsDirective) .provider('proxy',proxyProvider) // Functions only .config(function(proxyProvider){…}) .run(function(proxy){…});  name : 'myApp'  requires : [ 'bl'] _runBlocks : [ ] _configBlocks : [ ] _invokeQueue : [ ] 'MainCtrl',MainCtrl 'tabs',tabsDirective 'proxy',proxyProvider function(proxyProvider){…} function(proxy){…}
  • 5.  name : string  requires : [ ] _runBlocks : [ ] run( initializationFn ) _configBlocks : [ ] Config(function( xxxProvider ){ }) _invokeQueue : [ ] - controller(name, constructor) - directive (name, directiveFn) - filter (name, filterFactory) - animation (name, animationFactory) - service (name, constructor) - factory (name, providerFn) - provider (name, providerType) - decorator(name, fn ) - constant (name, object) - value (name, object)
  • 6. angular Modules (private) Browser <html lang="en" ng-app="app"> <body> <div class="view-container"> <div ng-view class="view-frame"></div> </div> <script src="lib/angular.js"></script> <!-- Angular Modules --> <script src="lib/angular-route.js"></script> <!-- My Modules --> <script src="js/app.js"></script> <script src="js/controllers.js"></script> <script src="js/services.js"></script> </body> </html> ngRoute app ctrls services DOM Content Loaded Event
  • 8. var injector = createInjector(modules); injector.invoke([ '$rootScope','$rootElement','$compile','$injector','$animate', function(scope, element, compile, injector, animate) { scope.$apply(function() { element.data('$injector', injector); compile(element)(scope); }); }] ); Create the injector and load the modules to the injector. Compile the root element and return link function. Execute the link function with the root scope. Apply, update the page
  • 9. angular Modules (private) ngRoute app ctrls services $injector (Instance Injector) Provider Injector Instance Cache Provider Cache Keys Values Invoke( )get( ) Keys Values instantiate( ) has( ) Invoke( )get( ) instantiate( ) has( )
  • 10. angular Modules (private) ngRoute app ctrls services <!-- app.js --> angular.module('app',['ngRoute','ctrls']) .config(function($routeProvider){}); <!-- angular-route.js --> angular.module('ngRoute',[]) .provider('$route',fn); <!-- controllers.js --> angular.module('ctrls',['services']) .controller('MainCtrl', fn); <!-- services.js --> angular.module('services',[]) .service('todoSer', fn); <html lang="en" ng-app="app">
  • 11. angular Modules (private) ngRoute app services Provider Injector Keys Values todoSer { $get : factoryFn } $controllerProvider Keys Values constructor $route { $get : factoryFn } config ctrls MainCtrl { $get : factoryFn } todoSer Provider $route Provider
  • 12. angular $injector Provider Injector Instance Cache Provider Cache Keys Values { $get : factoryFn } { $get : factoryFn } todoSerProvider $routeProvider Invoke( )get( ) Keys Values instantiate( ) has( ) Invoke( )get( ) instantiate( ) has( )
  • 13. angular Provider Injector Instance Cache Provider Cache Keys Values { $get : factoryFn } { $get : factoryFn } todoSerProvider $routeProvider angular.module('app',['ngRoute','ctrls'] .run(function runFn(todoSer){ todoSer.load(); }); Invoke( runFn )get( 'todoSer' ) get( 'todoSer' + 'Provider' ) Keys Values { . . .}todoSer
  • 15. // You write functions such as this one. function doSomething(serviceA, serviceB) { // do something here. } // Angular provides the injector for your application var $injector = ...; $injector.invoke(doSomething); var serviceA = $injector.get('serviceA'); var serviceB = $injector.get('serviceB'); doSomething(serviceA, serviceB);
  • 16. // inline option $injector.invoke( [ 'serviceA', function (serviceA) { } ] ); $injector.invoke( function (serviceA) { } ); $injector.invoke( function ( sa ) { } ); minified xxx.js xxx.min.js // annotated option explicit.$inject = ['serviceA']; function explicit(serviceA) { }; $injector.invoke(explicit);
  • 17. <ANY ng-app="angular.Module" [ng-strict-di="boolean"]> ... </ANY> Useful for debugging info, will assist in tracking down the root of these bugs.
  • 18. <html lang="en" ng-app="app"> <body> <script src="lib/angular.js"></script> <script src="lib/angular-route.js"></script> <script src="js/app.js"></script> </body> </html> angular.module('app', ['ngRoute']); The module file are being downloaded correctly The module name in the requires is not misspelled
  • 19. <html lang="en" ng-app="app"> <body ng-controller="Ctrl"> <script src="angular.js"></script> <script src="angular-route.js"></script> <script src="app.js"></script> </body> </html> angular.module('app', ['ngRoute']).controller('Ctrl', function(){...}); The module, where the provider / controller is defined, is loaded to the injector Spelled correctly