Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a repeater within a repeater, like so:

<div ng-repeat='x in collection1'>
    <div ng-repeat='y in collection2'>
    </div>
</div>

What I'm trying to do is access property y of object x, something like...

{{ x.{{y} }}}

or

{{ x[ {{y}} ] }}

...but when I try this I get an error along the lines of..."Syntax Error: Token 'y' is unexpected, expecting [:]."

Is there any way to do something like this with Angular or am I boned here?

share|improve this question
    
possible duplicate of How to access object using dynamic key? –  Stewie Jul 1 '13 at 23:36

1 Answer 1

up vote 3 down vote accepted
{{ x[y] }}

Here's a jsfiddle, though the example is a bit contrived.

share|improve this answer
    
Thanks. This was actually the first thing I'd tried, but it turns out my object wasn't set up like I expected. I was looking for x[firstName] when I needed x.name[first] etc. –  E-Rock Jul 2 '13 at 13:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.