So I\'m new to AngularJS and I\'m trying to build a very simple list app, where I can create an ng-repeat item list and then push a selected item into another ng-repeat list. Al
You'd be much better off using the same array with both lists, and creating angular filters to achieve your goal.
http://docs.angularjs.org/guide/dev_guide.templates.filters.creating_filters
Rough, untested code follows:
appModule.filter('checked', function() {
return function(input, checked) {
if(!input)return input;
var output = []
for (i in input){
var item = input[i];
if(item.checked == checked)output.push(item);
}
return output
}
});
and the view (i added an "uncheck" button too)
Add Item
Checked Items: {{getTotalCheckedItems()}}
Checked:
amount: {{item.amount}} -
name: {{item.name}} -
this item is checked!
Unchecked Items: {{getTotalItems()}}
Unchecked:
amount: {{item.amount}} -
name: {{item.name}} -
Then you dont need the toggle methods etc in your controller