AngularJS: Empty - latest CI build
HTML
<div ng-app='app' ng-controller='Main'>
<input type="text" ng-model="value" ng-model-onblur ng-change="update()">
{{value}}
</div>
JavaScript
function Main($scope)
{
$scope.update = function(){
alert('model updated');
}
}
// override the default input to update on blur
angular.module('app', []).directive('ngModelOnblur', function() {
return {
restrict: 'A',
require: 'ngModel',
priority: 1,
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());
});
});
}
};
});