Define event types » Add debounce to delay Model synchronisation » e.g. { debounce: 250 } = $digest ~250ms » $rollbackViewValue for undoing model changes
required ng-minlength="5" ng-maxlength="100"> </label> <div ng-messages="myForm.myField.$error" role="alert"> <div ng-message="required"> You did not enter a field </div> <div ng-message="minlength, maxlength"> Your email must be between 5 and 100 characters long </div> </div> </form>
» Iterates $$watchers Array on $scope » If model value is different from last calculated then corresponding listener executes » Exits loop, Angular loops again (10 max) » Repaints DOM (View expressions updated)
adds a watch to the $watch list » Only $watched if bound in the View » Dirty checked in the $digest loop » Minimise use of $$watchers / avoid if possible
the DOM » ng-if/switch for less frequent/heavier rendering » ng-show/hide toggle "ng-hide" class » ng-show/hide for more frequent/lighter rendering » ng-show/hide less performant due to $$watchers (when hidden)
$rootScope.$digest() if you're certain only child $scopes need updating » Improve performance by not forcing a full $rootScope.$digest » $scope.$digest runs on current and child $scopes » $scope.$apply triggers $rootScope.$digest call
tree comparison (expensive) » $watchCollection goes only one level deep » Shallow reference of all top level items » Try not to use either unless you have to » Not as testable » Signs of bad architecture » Litter Controllers
elsewhere var time = 1444175093303; // Parsed in JS before bound to the DOM this.parsedDate = $filter('date')(time, 'dd-MM-yyyy'); } angular .module('app') .controller('SomeCtrl', SomeCtrl);
side of each Directive/API you use » Consider using JavaScript over DOM bindings where possible ($filter etc.) » Check Angular's GitHub repo for changelogs/ releases