Q:

sweetalert isConfirm with angularjs

I have a sample code here where i wanted to continue or add new value using isConfirm with sweet alert as.
 swal({
      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 New. What is wrong with code?

A:

You have to use $scope.$apply();, otherwise it will not reflect the value in $scope variable.
DEMO
You can check here more info about $scope.apply().
I hope it helps!

