Created
June 30, 2014 17:30
-
-
Save ianmcnally/89dd4945d24b5cd2002d to your computer and use it in GitHub Desktop.
Update input on blur - Angular
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
# Only update <input> elements with bound angular models <input ng-model="my model"> on 'blur' event. | |
# Tweaked from a variety of places. | |
app.directive 'updateOnBlur', -> | |
require : 'ngModel' | |
link : (scope, element, attributes, ngModelController) -> | |
element.unbind 'input' | |
element.bind 'blur', -> | |
scope.$apply -> | |
ngModelController.$setViewValue element.val() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: this was before ng-model-options!