Reputation: 2760
I need to create variables dynamically inside ng-repeat
and initialize it using ng-init
.
<div data-ng-repeat="r in ['first','second','third']" data-ng-init="{{'panel'+$index}}=true">
{{'panel'+$index}}
</div>
The output of the above code is,
panel0
panel1
panel2
But I need the following output,
true
true
true
Here is the plunker.
Upvotes: 0
Views: 2825
Reputation: 8514
Try putting your values as an array:
<div id="{{'panel'+$index}}" data-ng-repeat="r in ['first','second','third']" data-ng-init="t['panel'+$index]=true">
{{t['panel'+$index]}}
</div>
Upvotes: 1