Alex Logist Alex Logist - 2 years ago 82
AngularJS Question

AngularJs LimitTo in ngShow/ngIf statement

I would like to do this:

ng-show="node.status | limitTo:1:1 == 1"


In a simple angular expression it works:
{{ node.status | limitTo:1:1 }}
=1

I can't get it to work in a ngShow or ngIf statement....

Answer Source

limitTo works only with ng-repeat, you cannot have on ng-if or ng-show

Creates a new array or string containing only a specified number of elements. The elements are taken from either the beginning or the end of the source array, string or number, as specified by the value and sign (positive or negative) of limit.

alternatively you can have a function that implements your logic and call it within ng-if or ng-show

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download