我結束了這段代碼:確認指令不起作用
MetronicApp.directive('confirmClick', ['SweetAlert',
function(SweetAlert) {
return {
priority: 100,
restrict: 'A',
scope: {
confirmClick: '&'
},
link: {
pre: function(scope, element, attr) {
var msg = attr.ngConfirmClick || "Are you sure?";
var clickAction = attr.confirmedClick;
element.bind('click touchstart', function(event) {
SweetAlert.swal({
title: "Are you sure?",
text: "Your will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: true
},
function(isConfirm) {
if (isConfirm) {
scope.confirmClick();
}
else{
return false;
}
});
});
}
}
};
}
]);
您收到哪個錯誤? – manzapanza
附註:切勿在您的指令名稱中使用'ng',這些應該是僅由角度創建的指令。讓其他開發者感到困惑!爲你/你的公司定製一個讓我們說'myConfirmClick' –
@manzapanza我沒有得到任何錯誤。但它不像一個確認。 – Burak