lundi 26 juin 2017

list of checkboxes in angular and ng-repeat.. All checkboxes check together? how to save check separately?

I'm creating a to-do list app with angular, pretty simple, but I am having an issue with the check boxes--- If I click one check box, they all get checked... How can I separate it so it only checks one at a time and then checks to save checked/unchecked boxes?

html

  <body ng-controller="HomeController as vm" ng-cloak>
<input type="text" placeholder="To do..." ng-model="vm.myTask">
<button type="button" ng-click="vm.submitTask()">Submit</button>
</br>

<label ng-repeat="Task in vm.myTasks">
<ul></li><input type="checkbox" value="" ng-model="vm.taskList"></li>
</ul>
</label>

homeController.js

//task array
var myTasks = [];

class HomeController {



//submit task from input value
submitTask(){
//push new task into array
  myTasks.push(this.myTask);

}
constructor(myTask){
this.myTasks = myTasks;
}



}

angular.module("myapp").controller("HomeController", HomeController);




Aucun commentaire:

Enregistrer un commentaire