Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
145
rated 0 times [  146] [ 1]  / answers: 1 / hits: 21726  / 9 Years ago, wed, july 1, 2015, 12:00:00

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 ?


More From » angularjs

 Answers
55

just write



var data = {name : sampleName, age : 18};
$scope.list.push(data);

[#65969] Monday, June 29, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
michelecarissab

Total Points: 730
Total Questions: 97
Total Answers: 110

Location: Uzbekistan
Member since Sat, Feb 27, 2021
3 Years ago
;