我有简单的指令,像这样:Angularjs指令创建点击事件
angular.module('docsTemplateUrlDirective', [])
.controller('Controller', ['$scope', function($scope) {
$scope.customer = {
name: 'Naomi',
address: '1600 Amphitheatre'
};
$scope.clicke = function(){
alert('test');
};
}])
.directive('myCustomer', function() {
return {
templateUrl: 'my-customer.html'
};
});
的index.html
<div ng-controller="Controller">
<div my-customer click-event='clicke()'></div>
</div>
我-customer.html
Name: {{customer.name}} Address: {{customer.address}}
<button>click</button>
,我想创建点击按钮的事件,然后在我的控制器 中使用此事件。 但我不知道该怎么做。 帮我看看。非常感谢。
您可以用'NG-click',不是吗? – aprok
整个指令应该是可点击的吗?如在,它是一个元素指令? – ellitt
'ng-click =“clicke($ event)”' – fracz