Delete an item from a collection in AngularJS

Share this video with your friends

Send Tweet

We are going to complete the bookmark management functionality by showing how to delete a bookmark from the bookmarks collection.

The source for this lesson can be found on Github. Tags correspond to the lesson.

Durgesh
Durgesh
~ 8 years ago

Hi,

Can we use the below code to delete the item from the list?

bookmarks.splice($index,1) on dom class "close".

Is it not correct way to go on production??

Thanks MG

venelinpetrov
venelinpetrov
~ 8 years ago

This is exactly what you should do

Ciprian
Ciprian
~ 7 years ago

Instead of: function functionName(parameter) { // ... }; $scope.functionName = functionName;

You can just declare it directly like this $scope.functionName = function (parameter) { // ... };

I find it more elegant.