Posts

Showing posts from November, 2014

Angularjs expression size and watches

In Angular you can explicitly register a watch and a callback to be called when it changes   e.g.      $scope.$watch(expression, callback) ..or implicitly using a binding expression  e.g.     {{userName}} Angular keeps track of all watches on scope so that it can detect when changes have occurred and thus update the DOM or call a watch callback. Angulars code to detect changes by evaluating all the watches is called the "digest loop". The digest loop stores the value of the watch expression evaluation and when next the cycle runs it compares the old value to newly computed expression value. If there are differences then it will eventually intelligently update the dom and/or call impacted watch callbacks (once all changes have been resolved) The awesome book "Mastering Web Application Development with AngularJS" explains this well in Chapter 11. Chapter 11 includes a section on performance tuning. One advice is to "Consider the size of expressions be

Thumbs up for Angular 2.0

wow! Big changes: ng-controllers - gone, $scope - gone, directives - gone, modules- gone, new language AtScript added... wow! Still learning about Angular 2.0. But honestly as I think about it, I like what I see so far in Angular 2.0: I like the new Directive syntax, write as a class and annotate; well ok by me, I mean, lets face it Directives in 1.x are ugly changing to use ES6 modules very logical and makes sense (Embers doing same) eliminating $scope is a good idea, I always felt its like a global space and way too easy to abuse, $scope use is already being minimized in latest best practices...so its on the way out already controllers are written as classes and annotated; not clear to me how to completely eliminate ng-controller, but I don't see controllers going away but rather how controllers are activated on a page is changing changes to html syntax look a little weird but I'm sure we'll learn that quickly AtScript adds some useful looking beh