admin管理员组文章数量:1356413
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/
本文标签: javascriptShow ngrepeat item only when value to display is not nullStack Overflow
版权声明:本文标题:javascript - Show ng-repeat item only when value to display is not null - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744066157a2585035.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论