SlideShare uma empresa Scribd logo
1 de 41
Module
Module
<html ng-app=”myApp” >
Config Filter Directive Factory Controller
Routes
Service
Value
Provider
Data Binding
Expression Syntax
Two way binding
<p>Hello {{name}}!</p>
One way binding
<p>Hello {{::name}}!</p>
Controller declare
/* recommended */
// dashboard.js
angular
.module('app')
.controller('DashboardController', DashboardController);
function DashboardController() { }
/* avoid */
angular
.module('app')
.controller('DashboardController', function() { })
controllerAs View Syntax
<!-- avoid -->
<div ng-controller="DashboardController">
{{ name }}
</div>
<!-- recommended -->
<div ng-controller="DashboardController as dashboard">
{{ dashboard.name }}
</div>
controllerAs Controller Syntax
/* avoid */
function DashboardController() {
this.name = {};
this.sendMessage = function() { };
}
/* recommended */
function DashboardController() {
var vm = this;
vm.name = {};
vm.sendMessage = function() { };
}
Why use controllerAs syntax
// avoid
<div ng-controller="parentContrl">
{{ title }}
<div ng-controller="ChildContrl">
{{ title }}
{{ $parent.title }}
</div>
</div>
app.controller('parentContrl', function () {
this.title = 'Some title';
});
app.controller('ChildContrl', function () {
this.title = 'Some title';
});
// recommend
<div ng-controller="parentContrl as parent">
{{ parent.title }}
<div ng-controller="ChildContrl as child">
{{ child.title }}
{{ parent.title }}
</div>
</div>
Working with Form
Form validation with HTML5
Form validation with Core Angular
Form validation with angular-auto-validate
source: https://github.com/jonsamwell/angular-auto-validate
Document: http://jonsamwell.github.io/angular-auto-validate/
Form animation
source: https://github.com/sachinchoolur/ladda-angular
Simple: http://sachinchoolur.github.io/ladda-angular/
Submit form with $http
Document: https://docs.angularjs.org/api/ng/service/$http
$http({
method: 'GET',
url: '/someUrl'
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
Event handle
ngClick
<ANY
ng-click="expression">
...
</ANY>
Work with JSON
[
{
"name":"Billy Williams",
"email":"bwilliams0@apple.com",
"job":"Actuary",
"skill":"PDF Creator",
"pic":"https://robohash.org/eanostrumincidunt.jpg?size=120x120u0026set=set1"
},
{
"name":"Steven Frazier",
"email":"sfrazier1@pinterest.com",
"job":"Design Engineer",
"skill":"NC-Verilog",
"pic":"https://robohash.org/repudiandaeomnisest.bmp?size=120x120u0026set=set1"
},
{
"name":"Doris Clark",
"email":"dclark2@uol.com.br",
"job":"Nurse Practicioner",
"skill":"Axis",
"pic":"https://robohash.org/providentvoluptateet.png?size=120x120u0026set=set1"
}
]
Show JSON with ngRepeat
<div ng-repeat="obj in myObj"> ... </div>
<ANY
ng-repeat="repeat_expression">
...
</ANY>
Example
Sorting
<div ng-repeat="obj in myObj | orderBy:sortType:sortReverse"> ... </div>
sortType: JSON field name
Params
sortReverse: ascending or descending
data
Filter
keyword: text for search
Params
<div ng-repeat="obj in myObj | filter:keyword"> ... </div>
Service
AngularJS world, the services are singleton objects or functions that carry out specific tasks. It holds
some business logic. Separation of concern is at the heart while designing an AngularJS application.
Your controller must be responsible for binding model data to views using $scope. It does not contain
logic to fetch the data or manipulating it.
There are 3 type of service factory, service, provider , you can use to communicate data between
controller also.
Factory
Factory Provider
Gives us the function's return value ie. You just create an object, add properties to it, then return that same
object.When you pass this service into your controller, those properties on the object will now be
available in that controller through your factory. (Hypothetical Scenario)
Singleton and will only be created once
Reusable components
Factory are a great way for communicating between controllers like sharing data.
Can use other dependencies
Usually used when the service instance requires complex creation logic
Cannot be injected in .config() function.
Used for non configurable services
If you're using an object, you could use the factory provider.
Service
Service Provider
Gives us the instance of a function (object)- You just instantiated with the ‘new’ keyword and you’ll add
properties to ‘this’ and the service will return ‘this’.When you pass the service into your controller,
those properties on ‘this’ will now be available on that controller through your service. (Hypothetical
Scenario)
Singleton and will only be created once
Reusable components
Services are used for communication between controllers to share data
You can add properties and functions to a service object by using the this keyword
Dependencies are injected as constructor arguments
Used for simple creation logic
Cannot be injected in .config() function.
If you're using a class you could use the service provider
Provider
Providers
● Syntax: module.provider( 'providerName', function );
Result: When declaring providerName as an injectable argument you will be provided with (new
ProviderFunction()).$get(). The constructor function is instantiated before the $get method is called -
ProviderFunction is the function reference passed to module.provider.
Providers have the advantage that they can be configured during the module configuration phase.
myApp.provider('helloWorld', function() {
// In the provider function, you cannot inject any
// service or factory. This can only be done at the
// "$get" method.
this.name = 'Default';
this.$get = function() {
var name = this.name;
return {
sayHello: function() {
return "Hello, " + name + "!"
}
}
};
this.setName = function(name) {
this.name = name;
};
});
//hey, we can configure a provider!
myApp.config(function(helloWorldProvider){ helloWorldProvider.setName('World'); });
Connect REST API with ngResource, $http
ngResource: https://docs.angularjs.org/api/ngResource
$http: https://docs.angularjs.org/api/ng/service/$http
function asyncGreet(name) {
var deferred = $q.defer();
setTimeout(function() {
deferred.notify('About to greet ' + name + '.');
if (okToGreet(name)) {
deferred.resolve('Hello, ' + name + '!');
} else {
deferred.reject('Greeting ' + name + ' is not allowed.');
}
}, 1000);
return deferred.promise;
}
var promise = asyncGreet('Robin Hood');
promise.then(function(greeting) {
alert('Success: ' + greeting);
}, function(reason) {
alert('Failed: ' + reason);
}, function(update) {
alert('Got notification: ' + update);
});
Directive
Directives are markers on a DOM element which attach a special behavior to it. For example, static HTML does not
know how to create and display a date picker widget. To teach HTML this new syntax we need a directive. The directive
will somehow create an element that behaves like a date picker. We will see how this is achieved subsequently.
syntax : app.directive('helloWorld', function() {...});
Directive
<!-- recommended -->
<my-calendar-range></my-calendar-range>
<div my-calendar-range></div>
/* recommended */
angular
.module('myApp)
.directive('helloWorld',helloWorld);
function helloWorld() {
var directive = {
link: link,
templateUrl: '/template/hello.html or <div> hello </div>',
restrict: 'EA'
};
return directive;
function link(scope, element, attrs) {
/* */
}
}
Directive isolate
● Share scope
● None isolate
● @ Local Scope Property
● = Local Scope Property
● & Local Scope Property
Share Scope
angular
.module('myApp')
.directive('sayHi',sayHi);
function sayHi() {
var directive = {
template: '<div> {{name}} </div>',
restrict: 'EA'
};
return directive;
}
angular
.module('myApp')
.controller('sayHi',hello);
function hello($scope) {
$scope.name = 'Hi';
}
Share scope
controller
$scope.name = 'Hi'
$scope.name = 'Hi'
directive
None isolate
angular
.module('myApp')
.directive('sayHi',sayHi);
function sayHi() {
var directive = {
scope: {},
template: '<div> {{name}} </div>',
restrict: 'EA'
};
return directive;
}
angular
.module('myApp')
.controller('sayHi',hello);
function hello($scope) {
$scope.name = 'Hi';
}
none isolate
controller
$scope.name = 'Hi'
$scope.name = 'Hi'
directive
@ Local Scope Property
angular
.module('myApp')
.directive('sayHi',sayHi);
function sayHi() {
var directive = {
scope: {name:'@'},
template: '<div> Hi {{name}} !!</div>',
restrict: 'EA'
};
return directive;
}
angular
.module('myApp')
.controller('sayHi',hello);
function hello($scope) {
$scope.name = 'Lisa';
}
@ scope
controller
<say-hi name={{name}}></say-hi>
Scope:{ name: '@' }
directive
Use to access string value
= Local Scope Property
angular
.module('myApp')
.directive('sayHi',sayHi);
function sayHi() {
var directive = {
scope: { people:'='},
template: '<div> Hi {{peopel.name}} !!</div>',
restrict: 'EA'
};
return directive;
}
angular
.module('myApp')
.controller('sayHi',hello);
function hello($scope) {
$scope.lisa = {
name.'Lisa';
age : 29
};
}
= scope two way binding
controller
<say-hi people=”lisa”></say-hi>
scope:{ people: '=' }
directive
Use to bind object
& Local Scope Property
angular
.module('myApp')
.directive('sayHi',sayHi);
function sayHi() {
var directive = {
scope: { people:'='},
template: '<ul><li ng-repeat="name in people">{{name}}</li></ul><button
ng-click="action()">swap</button>',
restrict: 'EA'
};
return directive;
}
angular
.module('myApp')
.controller('sayHi',hello);
function hello($scope) {
$scope.people = ['Lisa', 'John', 'Tom'];
$scope.swap = function() {
var j, x, i;
for (i = $scope.people.length; i; i -= 1) {
j = Math.floor(Math.random() * i);
x = $scope.people[i - 1];
$scope.people[i - 1] = $scope.people[j];
$scope.people[j] = x;
}
}
}
@ scope two way binding
controller
<say-hi people="people"
action="swap()"></say-hi>
scope:{ action: '&' }
directive
Use to call external function
Directive link function
angular
.module('myApp)
.directive('helloWorld',helloWorld);
function helloWorld() {
var directive = {
link: link,
templateUrl: '<div>{{name}}</div>',
restrict: 'EA'
};
return directive;
function link(scope, element, attrs) {
Scope.num = 2;
}
}
Routing app with uiRouter
Source & Document: https://github.com/angular-ui/ui-router
myApp.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/");
$stateProvider
.state('state1', {
url: "/state1",
templateUrl: "partials/state1.html"
})
.state('state2', {
url: "/state2",
templateUrl: "partials/state2.html"
});
});
Advance in Angular
Event in system $emit, $broadcast and $on via
$scope and $rootScope
Promise with $q and build-in $http
$q is a service that helps you run functions asynchronously, and use their return values (or
exceptions) when they are done processing.
This is an implementation of promises/deferred objects inspired by Kris Kowal's Q.
$q can be used in two fashions --- one which is more similar to Kris Kowal's Q or jQuery's Deferred implementations,
and the other which resembles ES6 (ES2015) promises to some degree.
Promise stop hell-callback
fn1(function() {
fn2(function() {
fn3(function() {
fn4(function() {
// your process
});
});
});
});
Deep dive a Scope
● Root Scope
● Child Scope
● Dot notation

Mais conteúdo relacionado

Mais procurados

Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016John Napiorkowski
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionVisual Engineering
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIVisual Engineering
 
AngularJS - Services
AngularJS - ServicesAngularJS - Services
AngularJS - ServicesNir Kaufman
 
ChtiJUG - Introduction à Angular2
ChtiJUG - Introduction à Angular2ChtiJUG - Introduction à Angular2
ChtiJUG - Introduction à Angular2Demey Emmanuel
 
Technozaure - Angular2
Technozaure - Angular2Technozaure - Angular2
Technozaure - Angular2Demey Emmanuel
 
Trustparency web doc spring 2.5 & hibernate
Trustparency web doc   spring 2.5 & hibernateTrustparency web doc   spring 2.5 & hibernate
Trustparency web doc spring 2.5 & hibernatetrustparency
 
AngularJS Internal
AngularJS InternalAngularJS Internal
AngularJS InternalEyal Vardi
 
Angular presentation
Angular presentationAngular presentation
Angular presentationMatus Szabo
 
JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"GeeksLab Odessa
 
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
 
Angular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of StatesAngular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of StatesOren Farhi
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features APIcgmonroe
 
Upgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.xUpgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.xEyal Vardi
 
Developing New Widgets for your Views in Owl
Developing New Widgets for your Views in OwlDeveloping New Widgets for your Views in Owl
Developing New Widgets for your Views in OwlOdoo
 
IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceParashuram N
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationEyal Vardi
 

Mais procurados (20)

Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS Introduction
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
 
AngularJS - Services
AngularJS - ServicesAngularJS - Services
AngularJS - Services
 
AngularJS.part1
AngularJS.part1AngularJS.part1
AngularJS.part1
 
ChtiJUG - Introduction à Angular2
ChtiJUG - Introduction à Angular2ChtiJUG - Introduction à Angular2
ChtiJUG - Introduction à Angular2
 
Technozaure - Angular2
Technozaure - Angular2Technozaure - Angular2
Technozaure - Angular2
 
AngularJS Basic Training
AngularJS Basic TrainingAngularJS Basic Training
AngularJS Basic Training
 
Trustparency web doc spring 2.5 & hibernate
Trustparency web doc   spring 2.5 & hibernateTrustparency web doc   spring 2.5 & hibernate
Trustparency web doc spring 2.5 & hibernate
 
AngularJS Internal
AngularJS InternalAngularJS Internal
AngularJS Internal
 
Angular presentation
Angular presentationAngular presentation
Angular presentation
 
JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"
 
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.
 
Angular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of StatesAngular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of States
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features API
 
Upgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.xUpgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.x
 
Extend sdk
Extend sdkExtend sdk
Extend sdk
 
Developing New Widgets for your Views in Owl
Developing New Widgets for your Views in OwlDeveloping New Widgets for your Views in Owl
Developing New Widgets for your Views in Owl
 
IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and Performance
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
 

Destaque

6 กลเม็ดการติดต่อสื่อสาร 6 powerful communication tips
6 กลเม็ดการติดต่อสื่อสาร 6 powerful communication tips 6 กลเม็ดการติดต่อสื่อสาร 6 powerful communication tips
6 กลเม็ดการติดต่อสื่อสาร 6 powerful communication tips maruay songtanin
 
(Hindi) Zuljanah - By: Syed ul Ulama Syed Ali Naqi Naqvi Sahab t.s.
(Hindi) Zuljanah - By: Syed ul Ulama Syed Ali Naqi Naqvi Sahab t.s.(Hindi) Zuljanah - By: Syed ul Ulama Syed Ali Naqi Naqvi Sahab t.s.
(Hindi) Zuljanah - By: Syed ul Ulama Syed Ali Naqi Naqvi Sahab t.s.Jamal Mirza
 
Sanntidsdata i ArcGIS - Esri norsk BK 2014
Sanntidsdata i ArcGIS -  Esri norsk BK 2014Sanntidsdata i ArcGIS -  Esri norsk BK 2014
Sanntidsdata i ArcGIS - Esri norsk BK 2014Geodata AS
 
Ilio Krumins Beens and Maureen McMahon: Kaplan Transition to Agile
Ilio Krumins Beens and Maureen McMahon: Kaplan Transition to AgileIlio Krumins Beens and Maureen McMahon: Kaplan Transition to Agile
Ilio Krumins Beens and Maureen McMahon: Kaplan Transition to Agilebisg
 
IPMA - Cel PMO? - Samolikwidacja, The goal of the PMO? Self-Destruction
IPMA - Cel PMO? - Samolikwidacja, The goal of the PMO? Self-DestructionIPMA - Cel PMO? - Samolikwidacja, The goal of the PMO? Self-Destruction
IPMA - Cel PMO? - Samolikwidacja, The goal of the PMO? Self-DestructionMichal Raczka
 
حدیثوں میں جس مسیح اور مہدی کا زکر ہے اس کا کیا ثبوت ہے کہ حضرت مرزا صاحب ہی ...
حدیثوں میں جس مسیح اور مہدی کا زکر ہے اس کا کیا ثبوت ہے کہ حضرت مرزا صاحب ہی ...حدیثوں میں جس مسیح اور مہدی کا زکر ہے اس کا کیا ثبوت ہے کہ حضرت مرزا صاحب ہی ...
حدیثوں میں جس مسیح اور مہدی کا زکر ہے اس کا کیا ثبوت ہے کہ حضرت مرزا صاحب ہی ...muzaffertahir9
 
Karbala ke dukhit Hussain a.s. - Ayatullah Al Uzma Syed Ali Naqi Naqvi t.s.
Karbala ke dukhit Hussain a.s. - Ayatullah Al Uzma Syed Ali Naqi Naqvi t.s.Karbala ke dukhit Hussain a.s. - Ayatullah Al Uzma Syed Ali Naqi Naqvi t.s.
Karbala ke dukhit Hussain a.s. - Ayatullah Al Uzma Syed Ali Naqi Naqvi t.s.Jamal Mirza
 
Mujahedaey Karbala - Part 01 - Syedul Ulema S. Ali Naqi Naqvi t.s.
Mujahedaey Karbala - Part 01 - Syedul Ulema S. Ali Naqi Naqvi t.s.Mujahedaey Karbala - Part 01 - Syedul Ulema S. Ali Naqi Naqvi t.s.
Mujahedaey Karbala - Part 01 - Syedul Ulema S. Ali Naqi Naqvi t.s.Jamal Mirza
 
Santiago Fajardo Palacio de Longoria
Santiago Fajardo Palacio de LongoriaSantiago Fajardo Palacio de Longoria
Santiago Fajardo Palacio de LongoriaSantiago Fajardo
 
GSP East 2008 - Intro & Welcome
GSP East 2008 - Intro & WelcomeGSP East 2008 - Intro & Welcome
GSP East 2008 - Intro & WelcomeDave McClure
 
LED pracovní světlo 18W 10-30V
LED pracovní světlo 18W 10-30VLED pracovní světlo 18W 10-30V
LED pracovní světlo 18W 10-30VRoel Adriaan Ramp
 
Content marketing för e-handel - fördjupning
Content marketing för e-handel - fördjupningContent marketing för e-handel - fördjupning
Content marketing för e-handel - fördjupningChrister Pettersson
 
Twitter, bloggar, Facebook och YouTube – var ska jag börja?
Twitter, bloggar, Facebook och YouTube – var ska jag börja?Twitter, bloggar, Facebook och YouTube – var ska jag börja?
Twitter, bloggar, Facebook och YouTube – var ska jag börja?Please copy me
 
Top 10 Rules for Vertical Revolutionaries
Top 10 Rules for Vertical RevolutionariesTop 10 Rules for Vertical Revolutionaries
Top 10 Rules for Vertical RevolutionariesDave McClure
 
8 Blogging Tools That You Need to Increase Traffic and Links
8 Blogging Tools That You Need to Increase Traffic and Links8 Blogging Tools That You Need to Increase Traffic and Links
8 Blogging Tools That You Need to Increase Traffic and LinksVenchito Tampon
 

Destaque (20)

2015 AYME MOOC PAPER
2015 AYME MOOC PAPER2015 AYME MOOC PAPER
2015 AYME MOOC PAPER
 
6 กลเม็ดการติดต่อสื่อสาร 6 powerful communication tips
6 กลเม็ดการติดต่อสื่อสาร 6 powerful communication tips 6 กลเม็ดการติดต่อสื่อสาร 6 powerful communication tips
6 กลเม็ดการติดต่อสื่อสาร 6 powerful communication tips
 
(Hindi) Zuljanah - By: Syed ul Ulama Syed Ali Naqi Naqvi Sahab t.s.
(Hindi) Zuljanah - By: Syed ul Ulama Syed Ali Naqi Naqvi Sahab t.s.(Hindi) Zuljanah - By: Syed ul Ulama Syed Ali Naqi Naqvi Sahab t.s.
(Hindi) Zuljanah - By: Syed ul Ulama Syed Ali Naqi Naqvi Sahab t.s.
 
Sanntidsdata i ArcGIS - Esri norsk BK 2014
Sanntidsdata i ArcGIS -  Esri norsk BK 2014Sanntidsdata i ArcGIS -  Esri norsk BK 2014
Sanntidsdata i ArcGIS - Esri norsk BK 2014
 
Ilio Krumins Beens and Maureen McMahon: Kaplan Transition to Agile
Ilio Krumins Beens and Maureen McMahon: Kaplan Transition to AgileIlio Krumins Beens and Maureen McMahon: Kaplan Transition to Agile
Ilio Krumins Beens and Maureen McMahon: Kaplan Transition to Agile
 
IPMA - Cel PMO? - Samolikwidacja, The goal of the PMO? Self-Destruction
IPMA - Cel PMO? - Samolikwidacja, The goal of the PMO? Self-DestructionIPMA - Cel PMO? - Samolikwidacja, The goal of the PMO? Self-Destruction
IPMA - Cel PMO? - Samolikwidacja, The goal of the PMO? Self-Destruction
 
حدیثوں میں جس مسیح اور مہدی کا زکر ہے اس کا کیا ثبوت ہے کہ حضرت مرزا صاحب ہی ...
حدیثوں میں جس مسیح اور مہدی کا زکر ہے اس کا کیا ثبوت ہے کہ حضرت مرزا صاحب ہی ...حدیثوں میں جس مسیح اور مہدی کا زکر ہے اس کا کیا ثبوت ہے کہ حضرت مرزا صاحب ہی ...
حدیثوں میں جس مسیح اور مہدی کا زکر ہے اس کا کیا ثبوت ہے کہ حضرت مرزا صاحب ہی ...
 
Karbala ke dukhit Hussain a.s. - Ayatullah Al Uzma Syed Ali Naqi Naqvi t.s.
Karbala ke dukhit Hussain a.s. - Ayatullah Al Uzma Syed Ali Naqi Naqvi t.s.Karbala ke dukhit Hussain a.s. - Ayatullah Al Uzma Syed Ali Naqi Naqvi t.s.
Karbala ke dukhit Hussain a.s. - Ayatullah Al Uzma Syed Ali Naqi Naqvi t.s.
 
Mujahedaey Karbala - Part 01 - Syedul Ulema S. Ali Naqi Naqvi t.s.
Mujahedaey Karbala - Part 01 - Syedul Ulema S. Ali Naqi Naqvi t.s.Mujahedaey Karbala - Part 01 - Syedul Ulema S. Ali Naqi Naqvi t.s.
Mujahedaey Karbala - Part 01 - Syedul Ulema S. Ali Naqi Naqvi t.s.
 
Santiago Fajardo Palacio de Longoria
Santiago Fajardo Palacio de LongoriaSantiago Fajardo Palacio de Longoria
Santiago Fajardo Palacio de Longoria
 
GSP East 2008 - Intro & Welcome
GSP East 2008 - Intro & WelcomeGSP East 2008 - Intro & Welcome
GSP East 2008 - Intro & Welcome
 
Core10
Core10Core10
Core10
 
LED pracovní světlo 18W 10-30V
LED pracovní světlo 18W 10-30VLED pracovní světlo 18W 10-30V
LED pracovní světlo 18W 10-30V
 
Content marketing för e-handel - fördjupning
Content marketing för e-handel - fördjupningContent marketing för e-handel - fördjupning
Content marketing för e-handel - fördjupning
 
Twitter, bloggar, Facebook och YouTube – var ska jag börja?
Twitter, bloggar, Facebook och YouTube – var ska jag börja?Twitter, bloggar, Facebook och YouTube – var ska jag börja?
Twitter, bloggar, Facebook och YouTube – var ska jag börja?
 
نظم نكت الانتصار
نظم نكت الانتصارنظم نكت الانتصار
نظم نكت الانتصار
 
Boost
BoostBoost
Boost
 
Top 10 Rules for Vertical Revolutionaries
Top 10 Rules for Vertical RevolutionariesTop 10 Rules for Vertical Revolutionaries
Top 10 Rules for Vertical Revolutionaries
 
8 Blogging Tools That You Need to Increase Traffic and Links
8 Blogging Tools That You Need to Increase Traffic and Links8 Blogging Tools That You Need to Increase Traffic and Links
8 Blogging Tools That You Need to Increase Traffic and Links
 
Swu
SwuSwu
Swu
 

Semelhante a AngularJs-training

Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto UniversitySC5.io
 
Dependency Injection pattern in Angular
Dependency Injection pattern in AngularDependency Injection pattern in Angular
Dependency Injection pattern in AngularAlexe Bogdan
 
CFUGbe talk about Angular JS
CFUGbe talk about Angular JSCFUGbe talk about Angular JS
CFUGbe talk about Angular JSAlwyn Wymeersch
 
First Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven DevelopmentFirst Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven DevelopmentNuvole
 
Angular Presentation
Angular PresentationAngular Presentation
Angular PresentationAdam Moore
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionDzmitry Ivashutsin
 
Get rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directivesGet rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directivesMarios Fakiolas
 
Angular resolver tutorial
Angular resolver tutorialAngular resolver tutorial
Angular resolver tutorialKaty Slemon
 
Custom AngularJS Directives
Custom AngularJS DirectivesCustom AngularJS Directives
Custom AngularJS Directivesyprodev
 
AngularJS Custom Directives
AngularJS Custom DirectivesAngularJS Custom Directives
AngularJS Custom Directivesyprodev
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014Ran Wahle
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Luka Zakrajšek
 
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...murtazahaveliwala
 
Patterns Are Good For Managers
Patterns Are Good For ManagersPatterns Are Good For Managers
Patterns Are Good For ManagersAgileThought
 

Semelhante a AngularJs-training (20)

AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto University
 
Dependency Injection pattern in Angular
Dependency Injection pattern in AngularDependency Injection pattern in Angular
Dependency Injection pattern in Angular
 
CFUGbe talk about Angular JS
CFUGbe talk about Angular JSCFUGbe talk about Angular JS
CFUGbe talk about Angular JS
 
First Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven DevelopmentFirst Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven Development
 
Angular Presentation
Angular PresentationAngular Presentation
Angular Presentation
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency Injection
 
Get rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directivesGet rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directives
 
Grails Advanced
Grails Advanced Grails Advanced
Grails Advanced
 
Angular resolver tutorial
Angular resolver tutorialAngular resolver tutorial
Angular resolver tutorial
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 
Custom AngularJS Directives
Custom AngularJS DirectivesCustom AngularJS Directives
Custom AngularJS Directives
 
AngularJS Custom Directives
AngularJS Custom DirectivesAngularJS Custom Directives
AngularJS Custom Directives
 
Angular js
Angular jsAngular js
Angular js
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)
 
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
 
Patterns Are Good For Managers
Patterns Are Good For ManagersPatterns Are Good For Managers
Patterns Are Good For Managers
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 

Último (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

AngularJs-training

  • 1.
  • 2. Module Module <html ng-app=”myApp” > Config Filter Directive Factory Controller Routes Service Value Provider
  • 4. Expression Syntax Two way binding <p>Hello {{name}}!</p> One way binding <p>Hello {{::name}}!</p>
  • 5. Controller declare /* recommended */ // dashboard.js angular .module('app') .controller('DashboardController', DashboardController); function DashboardController() { } /* avoid */ angular .module('app') .controller('DashboardController', function() { })
  • 6. controllerAs View Syntax <!-- avoid --> <div ng-controller="DashboardController"> {{ name }} </div> <!-- recommended --> <div ng-controller="DashboardController as dashboard"> {{ dashboard.name }} </div>
  • 7. controllerAs Controller Syntax /* avoid */ function DashboardController() { this.name = {}; this.sendMessage = function() { }; } /* recommended */ function DashboardController() { var vm = this; vm.name = {}; vm.sendMessage = function() { }; }
  • 8. Why use controllerAs syntax // avoid <div ng-controller="parentContrl"> {{ title }} <div ng-controller="ChildContrl"> {{ title }} {{ $parent.title }} </div> </div> app.controller('parentContrl', function () { this.title = 'Some title'; }); app.controller('ChildContrl', function () { this.title = 'Some title'; }); // recommend <div ng-controller="parentContrl as parent"> {{ parent.title }} <div ng-controller="ChildContrl as child"> {{ child.title }} {{ parent.title }} </div> </div>
  • 11. Form validation with Core Angular
  • 12. Form validation with angular-auto-validate source: https://github.com/jonsamwell/angular-auto-validate Document: http://jonsamwell.github.io/angular-auto-validate/
  • 14. Submit form with $http Document: https://docs.angularjs.org/api/ng/service/$http $http({ method: 'GET', url: '/someUrl' }).then(function successCallback(response) { // this callback will be called asynchronously // when the response is available }, function errorCallback(response) { // called asynchronously if an error occurs // or server returns response with an error status. });
  • 16. Work with JSON [ { "name":"Billy Williams", "email":"bwilliams0@apple.com", "job":"Actuary", "skill":"PDF Creator", "pic":"https://robohash.org/eanostrumincidunt.jpg?size=120x120u0026set=set1" }, { "name":"Steven Frazier", "email":"sfrazier1@pinterest.com", "job":"Design Engineer", "skill":"NC-Verilog", "pic":"https://robohash.org/repudiandaeomnisest.bmp?size=120x120u0026set=set1" }, { "name":"Doris Clark", "email":"dclark2@uol.com.br", "job":"Nurse Practicioner", "skill":"Axis", "pic":"https://robohash.org/providentvoluptateet.png?size=120x120u0026set=set1" } ]
  • 17. Show JSON with ngRepeat <div ng-repeat="obj in myObj"> ... </div> <ANY ng-repeat="repeat_expression"> ... </ANY> Example
  • 18. Sorting <div ng-repeat="obj in myObj | orderBy:sortType:sortReverse"> ... </div> sortType: JSON field name Params sortReverse: ascending or descending data
  • 19. Filter keyword: text for search Params <div ng-repeat="obj in myObj | filter:keyword"> ... </div>
  • 20. Service AngularJS world, the services are singleton objects or functions that carry out specific tasks. It holds some business logic. Separation of concern is at the heart while designing an AngularJS application. Your controller must be responsible for binding model data to views using $scope. It does not contain logic to fetch the data or manipulating it. There are 3 type of service factory, service, provider , you can use to communicate data between controller also.
  • 21. Factory Factory Provider Gives us the function's return value ie. You just create an object, add properties to it, then return that same object.When you pass this service into your controller, those properties on the object will now be available in that controller through your factory. (Hypothetical Scenario) Singleton and will only be created once Reusable components Factory are a great way for communicating between controllers like sharing data. Can use other dependencies Usually used when the service instance requires complex creation logic Cannot be injected in .config() function. Used for non configurable services If you're using an object, you could use the factory provider.
  • 22. Service Service Provider Gives us the instance of a function (object)- You just instantiated with the ‘new’ keyword and you’ll add properties to ‘this’ and the service will return ‘this’.When you pass the service into your controller, those properties on ‘this’ will now be available on that controller through your service. (Hypothetical Scenario) Singleton and will only be created once Reusable components Services are used for communication between controllers to share data You can add properties and functions to a service object by using the this keyword Dependencies are injected as constructor arguments Used for simple creation logic Cannot be injected in .config() function. If you're using a class you could use the service provider
  • 23. Provider Providers ● Syntax: module.provider( 'providerName', function ); Result: When declaring providerName as an injectable argument you will be provided with (new ProviderFunction()).$get(). The constructor function is instantiated before the $get method is called - ProviderFunction is the function reference passed to module.provider. Providers have the advantage that they can be configured during the module configuration phase.
  • 24. myApp.provider('helloWorld', function() { // In the provider function, you cannot inject any // service or factory. This can only be done at the // "$get" method. this.name = 'Default'; this.$get = function() { var name = this.name; return { sayHello: function() { return "Hello, " + name + "!" } } }; this.setName = function(name) { this.name = name; }; }); //hey, we can configure a provider! myApp.config(function(helloWorldProvider){ helloWorldProvider.setName('World'); });
  • 25. Connect REST API with ngResource, $http ngResource: https://docs.angularjs.org/api/ngResource $http: https://docs.angularjs.org/api/ng/service/$http
  • 26. function asyncGreet(name) { var deferred = $q.defer(); setTimeout(function() { deferred.notify('About to greet ' + name + '.'); if (okToGreet(name)) { deferred.resolve('Hello, ' + name + '!'); } else { deferred.reject('Greeting ' + name + ' is not allowed.'); } }, 1000); return deferred.promise; } var promise = asyncGreet('Robin Hood'); promise.then(function(greeting) { alert('Success: ' + greeting); }, function(reason) { alert('Failed: ' + reason); }, function(update) { alert('Got notification: ' + update); });
  • 27. Directive Directives are markers on a DOM element which attach a special behavior to it. For example, static HTML does not know how to create and display a date picker widget. To teach HTML this new syntax we need a directive. The directive will somehow create an element that behaves like a date picker. We will see how this is achieved subsequently. syntax : app.directive('helloWorld', function() {...});
  • 28. Directive <!-- recommended --> <my-calendar-range></my-calendar-range> <div my-calendar-range></div> /* recommended */ angular .module('myApp) .directive('helloWorld',helloWorld); function helloWorld() { var directive = { link: link, templateUrl: '/template/hello.html or <div> hello </div>', restrict: 'EA' }; return directive; function link(scope, element, attrs) { /* */ } }
  • 29. Directive isolate ● Share scope ● None isolate ● @ Local Scope Property ● = Local Scope Property ● & Local Scope Property
  • 30. Share Scope angular .module('myApp') .directive('sayHi',sayHi); function sayHi() { var directive = { template: '<div> {{name}} </div>', restrict: 'EA' }; return directive; } angular .module('myApp') .controller('sayHi',hello); function hello($scope) { $scope.name = 'Hi'; } Share scope controller $scope.name = 'Hi' $scope.name = 'Hi' directive
  • 31. None isolate angular .module('myApp') .directive('sayHi',sayHi); function sayHi() { var directive = { scope: {}, template: '<div> {{name}} </div>', restrict: 'EA' }; return directive; } angular .module('myApp') .controller('sayHi',hello); function hello($scope) { $scope.name = 'Hi'; } none isolate controller $scope.name = 'Hi' $scope.name = 'Hi' directive
  • 32. @ Local Scope Property angular .module('myApp') .directive('sayHi',sayHi); function sayHi() { var directive = { scope: {name:'@'}, template: '<div> Hi {{name}} !!</div>', restrict: 'EA' }; return directive; } angular .module('myApp') .controller('sayHi',hello); function hello($scope) { $scope.name = 'Lisa'; } @ scope controller <say-hi name={{name}}></say-hi> Scope:{ name: '@' } directive Use to access string value
  • 33. = Local Scope Property angular .module('myApp') .directive('sayHi',sayHi); function sayHi() { var directive = { scope: { people:'='}, template: '<div> Hi {{peopel.name}} !!</div>', restrict: 'EA' }; return directive; } angular .module('myApp') .controller('sayHi',hello); function hello($scope) { $scope.lisa = { name.'Lisa'; age : 29 }; } = scope two way binding controller <say-hi people=”lisa”></say-hi> scope:{ people: '=' } directive Use to bind object
  • 34. & Local Scope Property angular .module('myApp') .directive('sayHi',sayHi); function sayHi() { var directive = { scope: { people:'='}, template: '<ul><li ng-repeat="name in people">{{name}}</li></ul><button ng-click="action()">swap</button>', restrict: 'EA' }; return directive; } angular .module('myApp') .controller('sayHi',hello); function hello($scope) { $scope.people = ['Lisa', 'John', 'Tom']; $scope.swap = function() { var j, x, i; for (i = $scope.people.length; i; i -= 1) { j = Math.floor(Math.random() * i); x = $scope.people[i - 1]; $scope.people[i - 1] = $scope.people[j]; $scope.people[j] = x; } } } @ scope two way binding controller <say-hi people="people" action="swap()"></say-hi> scope:{ action: '&' } directive Use to call external function
  • 35. Directive link function angular .module('myApp) .directive('helloWorld',helloWorld); function helloWorld() { var directive = { link: link, templateUrl: '<div>{{name}}</div>', restrict: 'EA' }; return directive; function link(scope, element, attrs) { Scope.num = 2; } }
  • 36. Routing app with uiRouter Source & Document: https://github.com/angular-ui/ui-router myApp.config(function($stateProvider, $urlRouterProvider) { $urlRouterProvider.otherwise("/"); $stateProvider .state('state1', { url: "/state1", templateUrl: "partials/state1.html" }) .state('state2', { url: "/state2", templateUrl: "partials/state2.html" }); });
  • 38. Event in system $emit, $broadcast and $on via $scope and $rootScope
  • 39. Promise with $q and build-in $http $q is a service that helps you run functions asynchronously, and use their return values (or exceptions) when they are done processing. This is an implementation of promises/deferred objects inspired by Kris Kowal's Q. $q can be used in two fashions --- one which is more similar to Kris Kowal's Q or jQuery's Deferred implementations, and the other which resembles ES6 (ES2015) promises to some degree.
  • 40. Promise stop hell-callback fn1(function() { fn2(function() { fn3(function() { fn4(function() { // your process }); }); }); });
  • 41. Deep dive a Scope ● Root Scope ● Child Scope ● Dot notation

Notas do Editor

  1. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  2. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  3. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  4. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  5. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  6. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  7. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  8. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  9. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  10. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  11. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  12. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  13. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  14. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  15. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  16. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  17. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  18. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  19. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  20. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  21. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  22. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  23. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  24. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  25. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  26. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  27. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  28. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  29. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  30. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  31. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  32. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  33. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  34. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  35. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  36. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  37. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  38. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  39. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  40. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.
  41. What is a Module? You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc. Why? Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. There are several advantages to this approach: The declarative process is easier to understand. You can package code as reusable modules. The modules can be loaded in any order (or even in parallel) because modules delay execution. Unit tests only have to load relevant modules, which keeps them fast. End-to-end tests can use modules to override configuration.