Last active
August 29, 2015 14:03
-
-
Save vance/db40c407fdb81ba762ca to your computer and use it in GitHub Desktop.
Directive that watches scope for data changes
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
app.directive('alertSuccess', function() { | |
return { | |
require: 'ngModel', | |
link: function(scope, ele, attrs, ngModelController) { | |
scope.$watch(attrs.ngModel, function(value) { | |
//broadcast to your GlobalNotificationController to bring in a dialog etc. | |
scope.$emit('dataUpdated', value) | |
}); | |
} | |
}; | |
}); | |
//then in your html | |
<form name="newWidgetForm" novalidate alert-success> | |
<input name="name" type="text" ng-model="newWidgetCtrl.widget.name" ensure-expression="newWidgetCtrl.widget.name.length >= 5" required /> | |
... ... ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment