自定義指令

失去焦點事件

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);
;
}
};
} ]);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章