Skip to content

Commit

Permalink
Bonus - Add strong typing for $onChanges.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamGraber committed Apr 25, 2016
1 parent 8fac4e2 commit c430aee
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/watchInBindings/watchInBindings.ts
Expand Up @@ -2,6 +2,15 @@ import * as angular from 'angular';

export const moduleName: string = 'watchInBindings';

interface IChangeObject<T> {
currentValue: T;
previousValue: T;
}

interface IBindingChanges {
binding: IChangeObject<number>;
}

class WatchInBindingsParentController {
watchedValue: number;
}
Expand All @@ -20,7 +29,7 @@ class WatchInBindingsChildController {
binding: number;
doubledValue: number;

$onChanges(changes: any): void {
$onChanges(changes: IBindingChanges): void {
if (changes.binding) {
this.doubledValue = changes.binding.currentValue * 2;
}
Expand Down

0 comments on commit c430aee

Please sign in to comment.