Package manager
Package manager
Main file | Used by | Common Packages | |
---|---|---|---|
bower |
bower.json | client | angularjs bootstrap |
npm |
package.json | server | uglifyjs jasmine |
Build manager
Bower packages
Frontend code
npm packages
download
download
1
2
run
3
uses
to pack / treat
generates
4
frontend app
3a
3b
uses
5
Bower packages
Frontend code
npm packages
download
download
1
2
run
3
uses
to pack / treat
generates
4
frontend app
3a
3b
uses
5
Frontend app
loaded
service
service.setSomething(value)
service.getSomething()
view 1
view 2
controller 1 created
controller 2 created
controller 1 destroyed
controller 2 destroyed
Objects representing asynchronous calls
// some code
var promise = $http.get(...)
// more code, not waiting for $http.get() to finish
promise
.then(...)
.catch(...)
Code executed when the request is finished successfully
Code executed when the request is finished with an error
Providers: Services, Factories, Values
Host state and common logic through all the app
Directives
Reusable UI Components (with their own logic and template)
ngInclude (reusable views)
ngInclude to insert some html into another, combine with stand-alone less files.
Combine with $templateRequest and cache mechanisms to improve performance.
Other advanced javascript techniques
Adding common logic to javascript object prototypes...
::someVariable
When?
Values that, once loaded, won't change not dinamyc values)
Why?
Improve performance by reducing CPU and memory usage in client
Typical examples
Basically: https://github.com/angular/angular.js/wiki/Understanding-Scopes
JavaScript prototypical inheritance
aString visible for [ ChildScope ]
Basically: https://github.com/angular/angular.js/wiki/Understanding-Scopes
JavaScript prototypical inheritance
aString in [ ChildScope ] masks the one in [ ParentScope ]
Basically: https://github.com/angular/angular.js/wiki/Understanding-Scopes
JavaScript prototypical inheritance
aString in [ ChildScope ] masks the one in [ ParentScope ]
Basically: https://github.com/angular/angular.js/wiki/Understanding-Scopes
Why is this important for AngularJS?
Basically: https://github.com/angular/angular.js/wiki/Understanding-Scopes
Why is this important for AngularJS?
Having an ngModel inside an ngRepeat (or other directives creating child scopes) is, then, useless
Solution
Storing models in JS objects, not directly in the scope
ng-model="user.name"
Basically: https://github.com/angular/angular.js/wiki/Understanding-Scopes
Why is this important for AngularJS?
When making write operations on a model inside a child scope
$scope.someVar = "Some value"
Javascript is creating a new someVar in the child $scope instead of modifying the one in the parent scope