Angular. How to use checkboxes to add items to a list?

There is a list and the column with the chosen one. Each list item has a button, when clicked, it is added to the list. How to implement it in angular?
July 9th 19 at 13:53
2 answers
July 9th 19 at 13:55
this.list = ["item2"];
this.favourites = ["item1"];
this.toFavourites = function(id){
 this.list.splice(id, 1);

// using ng-repeat display the list
// in $index is stored the index of the element in the array
<button ng-click="Ctrl.toFavourites($index)">add To favourites</button>
July 9th 19 at 13:57
And how to make it so that when pressed again, it is not added again, and moved away? - nikita.Stracke commented on July 9th 19 at 14:00
: Well, to check whether an element in the array or not. If there is, delete it. - Kameron_Hilpert34 commented on July 9th 19 at 14:03
For example:
If it looks complicated, you can add js code that will be easier. - Bianka0 commented on July 9th 19 at 14:06
: Thank you very much))) - nikita.Stracke commented on July 9th 19 at 14:09

Find more questions by tags Angular