Skip to content

Commit

Permalink
Use $onChanges to track changes to one-way bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamGraber committed Apr 25, 2016
1 parent 11ba575 commit 3fb4501
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions source/watchInBindings/watchInBindings.ts
Expand Up @@ -20,11 +20,10 @@ class WatchInBindingsChildController {
binding: number;
doubledValue: number;

static $inject: string[] = ['$scope'];
constructor($scope: angular.IScope) {
$scope.$watch('controller.binding', (value: number): void => {
this.doubledValue = value * 2;
});
$onChanges(changes: any): void {
if (changes.binding) {
this.doubledValue = changes.binding.currentValue * 2;
}
}
}

Expand Down

0 comments on commit 3fb4501

Please sign in to comment.