On Github kmathur7 / angularjs_presentation
Config Block
Run Block
What does it mean?
$provider "provides" us with the dependencies that we need.
register a constant service with the module
store configurations
application wide variables
which do not change
.run(['VERSION','$rootScope',function(VERSION,$rootScope){ alert(VERSION); }]);
$scope is the glue between controller and view
$scope provides context
Whats the difference?
AngularJS allows you to bind methods as well as simple values
Used to provide deep linking.
Used to decide what View is to be loaded.
Requires separate sub-module
URL based.
Requires ngRoute sub-module
Use $routeProvider to define routes.
Maps the URL to a View and Controller combo.
Views are based on state of Application.
Requires ui.router sub-module
Use $stateProvider to define routes.
Maps the state to a View and Controller combo.
Allows nesting of views.
Is AngularJS compiled DOM
is the product of the $compile merging the html template with $scope
Layout Directives
Interaction Directives
ngif
ngShow/ngHide
ngRepeat
ngSwitch
ngInclude
ngModel
ngBlur/ngFocus
ngClick
ngSubmit
ngClass
core Angular Service
facilitates communication with remote HTTP servers
using XHR object or JSONP
is based on the deferred/promise API exposed by the $q service.
$http.get
$http.head
$http.post
$http.put
$http.delete
$http.jsonp
returned value of calling $http is a promise
use then method to register callbacks
callbacks recieve a single argument
an object representing the response.
Controllers should not talk to each other
use service to facilitate communication
$broadcast sends events downwards
$emit sends events upwards
$on listens for events
$rootScope
tells the compiler how a directive is supposed to be assembled.
Common Properties on the DDO are
Link Function, Controller Function
Restrict, Replace
template and templateUrl
Replace DOM element it is defined on with the directive template
Restricts the definition of the directive
E-Element
C-Class
M-Comment
A-Attribute
Replaces current content of DOM element with content of template loaded via templateUrl.
is where the DOM manipulation happens
comes with scope, element, attrs
element is a jQuery instance of the DOM element the directive is declared on.
attrs is a list of attributes declared on the element.
is constructed during the pre-linking phase
recieves $scope which is the current scope for the element.