I'm trying to create a button that would delete all complete items in a to do list --- after trying several different ways to accomplish this, I figure its probably easiest to just send checked items to one array, and unchecked items to another array, so I can make a button that just clears the checked items array... but nothing I am doing is working... thoughts?
html:
<input type="text" placeholder="To do..." ng-model="vm.myTask">
<button type="button" ng-click="vm.submitTask()">Submit</button>
<br>
<div ng-repeat="task in vm.myTasks" ng-class"'checkedbackground': task.checked">
<ul><li><input type="checkbox" value="" ng-model="task.checked"> <button type="button" ng-click="vm.myTasks.splice($index, 1)">Delete</button> </li>
</ul>
</div>
<button type="button" ng-click="vm.clearAll()"> Clear Complete</button>
homeController.js
var myTasks = [];
var completeTasks [];
class HomeController {
//submit task from input value
submitTask(){
//push new task into array
myTasks.push({name: this.myTask, checked: false});
}
constructor(myTask, checkedTask){
this.myTasks = myTasks;
}
clearAll(){
}
}
angular.module("myapp").controller("HomeController", HomeController);
I erased what I tried but some of what I tried involved this:
constructor(myTask, checkedTask){
this.myTasks = myTasks;
completeTasks.push({name: this.checkedTask, checked: true});
}
that broke the whole thing though.
Aucun commentaire:
Enregistrer un commentaire