This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
regression - cannot override blur event - Angular 1.2.0.rc3 #4473
Closed
Description
Im trying to override the blur event, but with 1.2.0-rc.3 it is broken
angular.module('mydirectives', []).directive('ngModelOnblur', function() {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, elm, attr, ngModelCtrl) {
if (attr.type === 'radio' || attr.type === 'checkbox') return;
elm.unbind('input').unbind('keydown').unbind('change');
elm.bind('blur', function() {
scope.$apply(function() {
ngModelCtrl.$setViewValue(elm.val());
});
});
}
};
});
html using directive
<input id="email" type="email" ng-model="user.email" name="userEmail" required ng-model-onblur/>
<div ng-show="form.userEmail.$error.email" class="alert-error alert-msg">the email is not valid</div>
If you change the version to 1.2.0-rc2 of angular it s working.
http://plnkr.co/edit/dRT5nh?p=preview
thanks
PS: maybe it is the unbind function, or something else