Angular JS
Angular architecture
● Angular component and Use case of it
● Some hands on
● Best practises
● FOCU
What is Angular JS?
MVC
Angular component
Controller
Service
Factory
Directives
Filter
View
Controller
● Setup the scope
● View Interaction
● Coordinate View and Model
● No DOM manipulationangular.module('myApp')
.controller('AddCarCtrl', ['$scope', function($scope) {
//do some stuff
}]);
Controller best practice
Less controller code
No application logic
No DOM manipulation
Service
Handle non-view logic
Communicate with server
Hold data & status
View
Display the Application
Declare Binding & Detectives
Create a Service
1. Value
2. Constant
3. Factory
4. Service
5. Providerangular.module('myApp').service('AddCarSvc',function($http,carList) {
//do some stuff
});
Directives
DOM manipulation
DOM events
Functionality( ng-show, ng-hide)
Widgets
Directives
Link
Controller
Scope
Project work though and hand on
https://github.com/dinushadev/angular-training.git
Set up dev environment with browser-sync
FOUC
Flash of unstyled Content
1. ng-cloak
[ng:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
display: none !important;
}
1. ng-bind
Use ng-bind instead of {{ }}
1. Add spinner
UI-Router
File Structure
Pros
● Two way binding
● Component oriented architecture with drectiview
● Rapid development
Cons
● Two way binding - formance issue.
● Rerendering
● With deep object graphs can cause slow app
Q

Angular js