mpsbhat mpsbhat - 3 months ago 16
AngularJS Question

sweetalert isConfirm with angularjs

I have a sample code here where i wanted to continue or add new value using

with sweet alert as.

title: "Are you sure?",
text: "Save the name",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Save and Add Another",
cancelButtonText: "New",
closeOnConfirm: true,
closeOnCancel: true
}, function(isConfirm) {
if (isConfirm) {
// saves the input values & selected values using ajax call
$scope.test = '';
} else {
// reset input values & selected values and fresh input again
$scope.test = '';
$scope.mysel = '-1';

But after clicking save and add another button the model value didn't clears at first time. Also it didn't resets on clicking of
. What is wrong with code?


You have to use $scope.$apply();, otherwise it will not reflect the value in $scope variable.


You can check here more info about $scope.apply().

I hope it helps!