kennechu kennechu - 6 months ago 50
AngularJS Question

Slice ng-repeat with AngularJS

An easy question from a noob in Angular.

I have my ng-repeat like this:

ng-repeat="f in drillDownList['D' +
d.merchMetrics.DEPT_NBR + 'CG' +
d.merchMetrics.CATG_GRP_NBR + 'C' +
d.merchMetrics.DEPT_CATG_NBR]


and I want to slice the last record because it's alway empty and it comes like that from the WS but I dont know how to achive this in AngularJS.

Answer

Inside ng-repeat you have available a variable $last.

example

<div ng-repeat="item in [1,2,3,4]">
  <div ng-if="!$last">{{item}}</div>
</div>

See more https://docs.angularjs.org/api/ng/directive/ngRepeat

Comments