Created
March 6, 2015 01:37
-
-
Save jserrao/05c9d544b6a924647398 to your computer and use it in GitHub Desktop.
React to a model change inside of controller using $watch (angular.js)
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
// professional.fullName validation, $watch looks at our model | |
// If our field's value is less than 4, we set the formElementErrorState variable to true | |
$scope.$watch("professional.fullName", function(newValue, oldValue) { | |
if ($scope.professional.fullName.length < 4) { | |
$scope.formElementErrorState = true; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment