如何在确认弹出按钮中禁用ng-click事件 1 [屏幕截图]
答案 0 :(得分:2)
你可以创建一个像这样的直接命令:
app.directive('ngConfirmClick', [
function(){
return {
link: function (scope, element, attr) {
var msg = attr.ngConfirmClick || "Are you sure?";
var clickAction = attr.confirmedClick;
element.bind('click',function (event) {
if ( window.confirm(msg) ) {
scope.$apply(clickAction);
}
});
}
};
}]);
你这样使用它:
<button confirmed-click="YourFunction()" ng-confirm-click="Are you really sure you want to do this ?">Action</button>