Show ng-repeat element only when the value to display is not zero

I just looked at learning AngularJS a few days ago. I have ng-repeat on an element, but I want to use ng-show somehow. This is my code now:

<p ng-repeat="(parameter,value) in object">{{parameter}}: {{value}}</p>

Which works well when an object is structured as

{"MobilePhone":null,"Email":"test@email.com","HomePhone":null}

I want to show only those elements that are not null. Sort of:

 <p ng-repeat="(parameter,value) in object" ng-show={{value}}>{{parameter}}: {{value}}</p>

But I don’t understand why the value is already available for ng-show? How can I do an if check before showing

?

Thanks for any help. If I were unclear, please contact for more information.

+3
source share
1 answer

This will work, and only if valueis really a value, it will be shown:

<p ng-repeat="(parameter,value) in obj" ng-show="value">{{parameter}}: {{value}}</p>

( ngIf)

: http://jsfiddle.net/zqJKH/

+5

All Articles