I just stared learning AngularJS few days ago. I have a ng-repeat on an element, but I want to use ng-show with it somehow as well. This is my code now:
<p ng-repeat="(parameter,value) in object">{{parameter}}: {{value}}</p>
Which works well where object is structured as
{"MobilePhone":null,"Email":"[email protected]","HomePhone":null}
I want to show only elements that don't have null as a value. Something like:
<p ng-repeat="(parameter,value) in object" ng-show={{value}}>{{parameter}}: {{value}}</p>
But I don't see why value would be available there for ng-show already? How can I do an "If" check for value before showing
?
Thanks for any help. If I was unclear, please ask for more info.
I just stared learning AngularJS few days ago. I have a ng-repeat on an element, but I want to use ng-show with it somehow as well. This is my code now:
<p ng-repeat="(parameter,value) in object">{{parameter}}: {{value}}</p>
Which works well where object is structured as
{"MobilePhone":null,"Email":"[email protected]","HomePhone":null}
I want to show only elements that don't have null as a value. Something like:
<p ng-repeat="(parameter,value) in object" ng-show={{value}}>{{parameter}}: {{value}}</p>
But I don't see why value would be available there for ng-show already? How can I do an "If" check for value before showing
?
Thanks for any help. If I was unclear, please ask for more info.
Share Improve this question asked Jan 31, 2014 at 10:01 trainoasistrainoasis 6,72112 gold badges54 silver badges83 bronze badges1 Answer
Reset to default 6This will work, and only if value
is a truly value it will be shown:
<p ng-repeat="(parameter,value) in obj" ng-show="value">{{parameter}}: {{value}}</p>
(You can also use ngIf
instead)
Example: http://jsfiddle/zqJKH/