The call.confirm function is always called.

I call the .confirm phonegap notification when using angular -js.

I have code like:

ng-click= func(item)

$scope.func = function(item) {
navigator.notification.confirm('Delete?', func2(item));
}

function func2 (item) {
console.log("Ohk call");
}

I want func2 to be called only when the user clicks the confirmation button in the confirmation field. But what happens is that it is called as soon as a notification appears without pressing any button. How to solve this problem?

+5
source share
2 answers

Here is the correct answer to him:

$scope.func= function (item) {
        navigator.notification.confirm('Delete?', function(button) {
            if ( button == 1 ) {
                func2(item);
            }
        });
    };

The button value is 1/2, based on which button the "Confirm" / "Cancel" button is pressed. In my case, the “confirm” button had a value of 1 and, therefore, an equality check.

+8
source

, func2 func. , :

$scope.func = function(item) {
    navigator.notification.confirm('Delete?', function() {
        func2(item)
    });
}

, .

+2

All Articles