Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create list of object with angularjs

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 ?

like image 428
user567 Avatar asked Jul 01 '15 11:07

user567


1 Answers

just write

var data = {name : "sampleName", age : 18};
$scope.list.push(data);
like image 51
binariedMe Avatar answered Sep 30 '22 07:09

binariedMe