Created
November 19, 2014 13:45
-
-
Save JArmando/7538f67c2d671b46a767 to your computer and use it in GitHub Desktop.
A directive that allows displaying an invalid modelValue in angular and triggers validations
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
directives.directive 'displayInvalid', () -> | |
restrict: 'A', | |
require: 'ngModel', | |
link: (scope, elm, attrs, model) -> | |
displayed = false | |
scope.$watch attrs.ngModel, (newValue, oldValue, scope) -> | |
if displayed is false and oldValue isnt undefined | |
displayed = true | |
elm.val model.$modelValue | |
model.$setViewValue(model.$modelValue) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment