Reputation: 3852
I have an array of strings, I use this code to add a new item
$scope.list.push(name);
But I don't want to add only the name, I want to do something like
$scope.list.push(data); // data contain name and age
How can I create data object ?
Upvotes: 8
Views: 22216
Reputation: 4329
just write
var data = {name : "sampleName", age : 18};
$scope.list.push(data);
Upvotes: 8