Julian Be Julian Be - 5 months ago 17
Javascript Question

Push Item From One Array Into another Array in Angular



I am programming an app with AngularJS and wanted to know how to push an item from one array into another array.

Here is sample code:

$scope.tasks = [
{title: "Do the dishes"},
{title: "Walk the dog"},
];
$scope.addToTasksDone = function() {// IM FAILNG HERE};
$scope.tasksDone = [];


How can I push the item with value "Do the dishes" to the tasksDone array?

Answer
$scope.tasks = [
{title: "Do the dishes"},
{title: "Walk the dog"},
];
$scope.tasksDone = [];
$scope.addToTasksDone = function(index) {// IM FAILNG HERE};
$scope.tasksDone.push($scope.tasks[index]);
}
Comments