I am working with a series of items that are structured as described below. Unfortunately, I do not have control over the variable names.
pubDate0, pubDate1, pubDate2
To access them, I currently use the following format:
<div>
<i>
{{newsData.pubDate0[0]}}
</i>
</div>
<div>
<i>
{{newsData.pubDate1[0]}}
</i>
</div>
<div>
<i>
{{newsData.pubDate2[0]}}
</i>
</div>
Is there a way to concatenate these variable names using ng-repeat
in order to avoid writing repetitive code?
I have attempted various approaches within an ng-repeat
loop, but none have been successful.
<p ng-repeat="t in getTimes(10) track by $index"> //looping 10 times
{{(newsData.pubDate+$index+[0])}}
</p>
//Some of the attempts made:
{{(newsData.pubDate+$index+[0])}}
{{('newsData.pubDate'+$index+[0])}}
{{('newsData.pubDate'+$index+'[0]')}}
{{newsData.pubDate+$index+[0]}}
{{newsData.pubDate+($index)+[0]}}
{{newsData.pubDate+{{$index}}+[0]}}
{{newsData.pubDate($index)[0]}}
{{newsData.pubDate$index[0]}}
{{newsData.pubDate{{$index}}[0]}}
{{newsData.pubDate+$index+[0]}}
Feeling somewhat stuck at this point. :(