Can you use a variable to replace firstP in the ng-repeat Directive?
Absolutely, you can replace firstP
with a variable by utilizing standard javascript object bracket notation within Angular.
Solution:
If your objective is to dynamically display the contents of the people
object, here's how you can achieve it:
<div ng-repeat="(key, value) in people">
<select>
<option ng-repeat="option in value">{{option}}</option>
</select>
</div>
In this solution, iterate over the keys of the people
object and for each key, access the respective array to display its elements.
Note:
You have the option to directly use value
instead of people[key]
as in ng-repeat="option in value"
.
The reference to people[key]
was solely for illustrative purposes.
Demo:
For a demonstration, check out this Plunker.