失去焦點事件
app.directive('ngBlur', function (AjaxService) {
return {restrict: 'A',
link: function (scope, element, attr) {
element.bind('blur', function(evt) {
});
}
};
});
設置元素焦點
app.directive('setFocus',[ function() {
return {
scope : false,
link : function(scope, element,attrs) {
var name =attrs.ngModel;
scope.$watch(name,function(newValue,oldValue, scope) {
if (!newValue) {
element[0].focus();
}
}, true);
;
}
};
} ]);