Angular JS hide first element of ng-repeat

Nick Cooper picture Nick Cooper · Apr 1, 2013 · Viewed 36.4k times · Source

How would I hide the first element of an ng-repeat?

<div ng-repeat="item in items" ng-hide="true">
    <div>{{ item.value }}</div>
</div>

This works in that the whole ng-repeat block is hidden, but how would I hide only the first item in items? I want to display it completely differently using more prominent html/etc, so it's useful to have it in that list of data.

Answer

Xesued picture Xesued · Apr 1, 2013

You can do this

<div ng-repeat="item in items" ng-show="!$first">
    <div>{{ item.value }}</div>
</div>

Here are the docs: http://docs.angularjs.org/api/ng.directive:ngRepeat