It is possible to use an ng-repeat
to achieve the following compiled DOM:
<div class="container">
<!-- ngRepeat item in items -->
<div ng-repeat="item in items">Item 1</div>
<!-- end ngRepeat: item in items -->
<!-- ngRepeat item in items -->
<div ng-repeat="item in items">Item 2</div>
<!-- end ngRepeat: item in items -->
<!-- ngRepeat item in items -->
<div ng-repeat="item in items">Item 3</div>
<!-- end ngRepeat: item in items -->
<div class="wrapper">
<!-- ngRepeat item in items -->
<div ng-repeat="item in items">Item 4</div>
<!-- end ngRepeat: item in items -->
<div ng-repeat="item in items">Item 5</div>
<!-- end ngRepeat: item in items -->
</div>
</div>
i.e. to have the last n items wrapped in an another element.
It might seem like a strange request and I understand it would be trivial to achieve this using two ng-repeat
directives. However, it needs to be a single ng-repeat
so that I can move items in and out of the wrapper without them being added and removed from the DOM (in a manner described here).
What I'm trying to achieve is a news-ticker style scrolling effect by giving the .wrapper
element overflow:hidden
and using javascript animate the top
position of the child elements. To be honest I'd rather not have to have a wrapper element at all but I'm not sure there is any other way to achieve the scrolling effect I require. Perhaps manipulating the clip
property to achieve the effect could work but I'm not entirely sure.
So it is possible to apply a wrapper element to some items in an ng-repeat
?