8

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 ?

2
  • Show complete code. Commented Jul 1, 2015 at 11:09
  • 3
    var data={"name":"user","age":15};$scope.list.push(data); Commented Jul 1, 2015 at 11:10

1 Answer 1

8

just write

var data = {name : "sampleName", age : 18};
$scope.list.push(data);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.