One-time binding syntax: In newer versions of Angular (v1.3.0-beta.10+), use the one-time binding syntax {{ ::value }}
where it makes sense
// avoid
<h1>{{ vm.title }}</h1>
// recommended
<h1>{{ ::vm.title }}</h1>
Why? : Binding once removes the watcher from the scope's $$watchers
array after the undefined
variable becomes resolved, thus improving performance in each dirty-check
Consider $scope.$digest: Use $scope.$digest
over $scope.$apply
where it makes sense. Only child scopes will update
$scope.$digest();
Why? : $scope.$apply
will call $rootScope.$digest
, which causes the entire application $$watchers
to dirty-check again. Using $scope.$digest
will dirty check current and child scopes from the initiated $scope