0

I have a table of users, each row representing a user. On the end of each row I have a delete link, which when clicked deletes the user from database.

Now I need to update the table to reflect the changes. I know how I would do this with jQuery, but how do I do it the angular way? Do I need to add a ng-model attribute to each row?

This is how I have attached the click event:

<a ng-click="deleteUser(user._id)">Delete</a>

I have a <tr ng-repeat="user in users"></tr> printing out the users. I'm thinking if I remove the user from the model, that might be the way to go.

EDIT: I found now this question, which also answer my question.

Community
  • 1
  • 1
ptf
  • 3,210
  • 8
  • 34
  • 67

1 Answers1

0

Yes you are correct. Use ng-repeat to render the list of users and on delete remove the user from the users list. Since it's a two way binding it will dynamically update the tr's.

Also on ng-click, you would need to call a $http service which will tell the database to delete the required user from DB. Use factory/service to create a $http service.

msapkal
  • 8,268
  • 2
  • 31
  • 48