In example like this:
<div ng-repeat="i in ['1','2']" id="tab-{{i}}">
<div ng-repeat="e in myCollection">
</div>
</div>
In the first iteration of the second ng-repeat I'd like to get first element of myCollection and in the second iteration I'd like to get the rest of the collection:
So why can't I do something like this:
<div ng-repeat="i in ['1','2']" id="tab-{{i}}">
<div ng-repeat="e in i == 1 ? _.first(myCollection) : _.rest(myCollection, 1)">
</div>
</div>
underscore.js methods are so helpful, but unfortunately this trick wouldn't work.
So how can I do something like that, right in the markup without involving code-behind javascript? I know, I know it's probably ain't right thing to do, nevertheless I'm curious if it's possible...
Angular expressions look like javascript, but are actually a subset of it, and do not allow any kind of control flow statements in them. To accomplish what you want to do, you'l need to set up your inner ng-repeat arrays in a controller.