gpt4 book ai didi

html - 如何在确认弹出按钮中禁用 ng-click 事件

转载 作者:行者123 更新时间:2023-11-27 23:36:59 25 4
gpt4 key购买 nike

如何在确认弹出按钮中禁用 ng-click 事件 1 [屏幕截图]

最佳答案

你可以创建一个这样的指令:

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>

关于html - 如何在确认弹出按钮中禁用 ng-click 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33478237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com