通过确认从X-editable中删除行(AngularJS)

时间:2021-11-29 21:16:51

I added a confirmation to the delete button, I noticed that the row has not been removed, and the code work fine.

我在删除按钮上添加了一个确认,我注意到该行尚未删除,代码工作正常。

HTML

<button class="btn btn-danger" confirmed-click="removeUser($index)" ng-confirm-click="Would you like to delete this user?">del</button>

JavaScript

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.$eval(clickAction)
                    }
                });
            }
        };
    }
]);

This is the EXAMPLE.

这是例子。

Please help.

1 个解决方案

#1


2  

The solution is to replace:

解决方案是替换:

scope.$eval(clickAction)

by

scope.$apply(clickAction)

Working EXAMPLE.

#1


2  

The solution is to replace:

解决方案是替换:

scope.$eval(clickAction)

by

scope.$apply(clickAction)

Working EXAMPLE.