1

this is my code for delete particular row in table on form in angular.

its working but not properly. Problem is when i click on delete button only pop ups comes.after that nothing happens. when i refresh my page on refresh that particular row deletes.

So everytime i have to refresh page to see delete works or not? How to solve this issue so i dont have to refresh my page evertytime after delete something.

<a ng-click="deleteInfo(detail)" onclick="return confirm('Are you sure
 you wish to delete this Record?');">
M. Eriksson
  • 13,450
  • 4
  • 29
  • 40
mahadev sutar
  • 171
  • 2
  • 16

3 Answers3

0

it's because only your onclick triggered in this scenario, you should use a custom directive to achieve this, like :

module.directive( "mwConfirmClick", [
  function( ) {
    return {
      priority: -1,
      restrict: 'A',
      scope: { confirmFunction: "&mwConfirmClick" },
      link: function( scope, element, attrs ){
        element.bind( 'click', function( e ){
          // message defaults to "Are you sure?"
          var message = attrs.mwConfirmClickMessage ? attrs.mwConfirmClickMessage : "Are you sure?";
          // confirm() requires jQuery
          if( confirm( message ) ) {
            scope.confirmFunction();
          }
        });
      }
    }
  }
]);

please refere to this old post

Community
  • 1
  • 1
jay liu
  • 129
  • 8
0

Use sweet-alert for confirmation except "onclick" method

http://t4t5.github.io/sweetalert/

Ravi Kumar
  • 58
  • 1
  • 7
0

You can write your confirm alert inside the ng-click function.

scope.deleteInfo = function(detail){
  $ngBootbox.confirm('Are you sure you wish to delete this Record?')
 .then(function() {
     //either you can reload window or delete the particular ng-model or whatever
  },
   function() {
   }); 
return false;
}
Indhu
  • 371
  • 1
  • 5
  • 18