Front End Developer
Front End Developer

Reputation: 41

Accessing objects in Angularjs

Is it possible to get age object's value with the name object on following mentioned AngularJS expression:

{{{name: 'Jhon', age: '15' }.name}}

Upvotes: 2

Views: 44

Answers (2)

Shashank
Shashank

Reputation: 2060

You can do something like below:

<div>
  Name = {{ {name: 'Jhon', age: '15' }.name | json }}
</div>
<div>
  Age = {{ {name: 'Jhon', age: '15' }.age | json }}
</div>

Have a look at the demo.

Upvotes: 1

ajaykumar
ajaykumar

Reputation: 656

Yes, but with a slight modification Eg.

({key : 1}).key

But you cannot use this object elsewhere. So there is no point in creating such objects unless you are referring via a variable.

Upvotes: 0

Related Questions