user567
user567

Reputation: 3852

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 ?

Upvotes: 8

Views: 22216

Answers (1)

binariedMe
binariedMe

Reputation: 4329

just write

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

Upvotes: 8

Related Questions