Created
September 20, 2015 16:24
-
-
Save Donmclean/a3d0a21a4d93b889c314 to your computer and use it in GitHub Desktop.
Using Angular Watch Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MyController($scope) { | |
$scope.myVar = 1; | |
$scope.$watch('myVar', function() { | |
alert('hey, myVar has changed!'); | |
}); | |
$scope.buttonClicked = function() { | |
$scope.myVar = 2; // This will trigger $watch expression to kick in | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment