0

I have the below

<tr ng-repeat="sce in users">
  <td>
    <a href="/test/delete?id={{sce.id}}" 
        onclick="return confirm('You really want to delete'+ {{sce.name}} + 'from list');" >
           <span aria-hidden="true" class="glyphicon glyphicon-remove-circle"></span>
    </a>
  </td> 
</tr>

But when I clicked, go to delete, I didnt see the alert

I got the error in console:

Error: [$compile:nodomevents] http://errors.angularjs.org/1.5.3/$compile/nodomevents
sirdaiz
  • 250
  • 3
  • 16
  • Have a look at the documentation for the error https://docs.angularjs.org/error/$compile/nodomevents - basically you cant append `{{sce.name}}` and you should extract this to a function – MikeS Mar 05 '20 at 11:44

1 Answers1

0

Try this solution:

<a href="/test/delete?id={{sce.id}}" 
    ng-click="showAlert($event, sce.name)" >

Add the method like this into the controller:

$scope.showAlert = (event, name) => { 
   event.preventDefault(); 
   let result = confirm('You really want to delete'+ name + 'from list');
   if(result) {
     // Do a rest api to delete the item
   }
}
Simone Boccato
  • 199
  • 1
  • 14