From 3fb45010bad9ff413932621d51c32cc2cb6c7f07 Mon Sep 17 00:00:00 2001 From: SamGraber Date: Mon, 25 Apr 2016 12:06:57 -0400 Subject: [PATCH] Use $onChanges to track changes to one-way bindings. --- source/watchInBindings/watchInBindings.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/watchInBindings/watchInBindings.ts b/source/watchInBindings/watchInBindings.ts index 9307d0f..5baa176 100644 --- a/source/watchInBindings/watchInBindings.ts +++ b/source/watchInBindings/watchInBindings.ts @@ -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; + } } }