Skip to content

Instantly share code, notes, and snippets.

@jserrao
Created March 6, 2015 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jserrao/05c9d544b6a924647398 to your computer and use it in GitHub Desktop.
Save jserrao/05c9d544b6a924647398 to your computer and use it in GitHub Desktop.
React to a model change inside of controller using $watch (angular.js)
// 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