Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
67
rated 0 times [  74] [ 7]  / answers: 1 / hits: 18348  / 8 Years ago, sat, july 2, 2016, 12:00:00



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?


More From » arrays

 Answers
14
$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]);
}

[#61543] Thursday, June 30, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
destanyb

Total Points: 407
Total Questions: 88
Total Answers: 88

Location: Senegal
Member since Mon, Sep 5, 2022
2 Years ago
;