vendredi 17 février 2017

Check and uncheck checkbox with Angular

In my form I have a table with checkbox in all of these columns. I have 3 <tr> and each <tr> has its ng-repeate calling the webservice to display the clones (Json data). When I click on a checkbox I generate a js array using this code :

checkoptions (array, model) {
angular.forEach(array, (value, key) => {
  if (array[key].checked) {
    model.push(array[key].id)
  }
})

And in HTML I use ng-change et ng-modelin the input of the checkbox

It works, but the problem is that when I uncheck a checkbox it is not removed from the js array




Aucun commentaire:

Enregistrer un commentaire