This tries to compare two way databinding implimentation of angularjs and knockout js. And tries to describe how angularjs dirty checking works. And also some angularjs best practices at the end.
18. Summery
• Observables has better performance than dirty checking
• Dirty checking is slow when model grows
• Synchronous vs asynchronous bindings
• Computed properties in dirty checking does not have a meaning like
in observables
20. Efficient $watch function
• dirty checking function must be efficient
• Will be evaluated large number of times
• Do not do DOM access (DOM => cost ) inside the $watch functions
22. Ng-if vs. ng-show
• The ng-If directive removes or recreates a portion of the DOM tree
based on an {expression}
• The ng-Show directive shows or hides the given HTML element based
on the expression
23. $eval and $parse
• $eval uses $parse inside it
for(i=0;i<100;i++){
var value=$scope.$eval(exp)
}
Var parsed =$parse(exp);
for(i=0;i<100;i++){
var value= parsed($scope);
}
24. Watch only what is needed
$watch(someObject,function(){
})
$watch(someObject,function(){
},true )
Deep Watchshallow watch
26. Directives for Performance improvements
• Bind once
• Fast-bind , notify –bind
• Bind sometimes ,not all the time ?
27. Angular 2.0
• AngularJS 2 is a framework for mobile apps. It is for desktop as well,
but mobile is the hard bit that we will get right first.
• All code in AngularJS 2 is already being written in ES6.
• Faster change detection (Object.observe())
$evalAsync ; it should run after the DOM has been manipulated by Angular, but before the browser renders
http://plnkr.co/edit/Mxhf1m3ae4dlZKk370Dh?p=info
http://plnkr.co/edit/2DViEccXH1049GsTxFho?p=preview
user interaction, timer event, or network event
https://docs.angularjs.org/guide/scope