【发布时间】:2015-11-19 08:10:10
【问题描述】:
我在自定义指令中使用 ng-blur 时遇到问题。我想要的是能够制作一个可以处理发送到指令上ng-blur 属性的任何类型函数的组件。
这是指令示例:
<az-dir ng-blur="change()" lid="test" ng-model="obj.test"></az-dir>
Javascript 指令
app.directive('azDir', azDir);
function azDir() {
return {
restrict: 'E',
scope: {
ngModel: '=',
ngBlur: '=',
lid: '@'
},
templateUrl: 'directive.html',
replace: true,
require: 'ngModel'
};
}
简单的角度控制器:
var app = angular.module('ashtest', []);
app.controller('TopCtrl', ['$scope',
function($scope) {
$scope.obj = {
test: "Ashkan"
};
$scope.change = function() {
$scope.obj.test = "changedThis";
}
}
]);
【问题讨论】:
标签: angularjs angular-directive