我有以下指令傳遞事件參數的自定義指令
.directive('uiBlur', function() {
return function(scope, elem, attrs) {
elem.bind('blur', function() {
scope.$apply(attrs.uiBlur);
});
};
})
這是HTML
<input id="mainOdd1Id" type="number" ng-model="data.mainOdd1" placeholder="#1 Main Odd" onfocus="this.placeholder=''" min="0" step="any" ui-Blur="testfn('data.mainOdd1', $event, '#1 Main Odd');">
而且這是在控制器的功能
$scope.testfn = function(propertyName, $event, placeHolder){
alert(propertyName);
}
我看到調試器$ event是未定義的...
這裏有什麼問題?
感謝
試試這個,NG-點擊=「MYFUNC( 'data.mainOdd1',{$事件:$事件},」#1 Main Odd') –