根据Angularjs中的值json隐藏元素

Fan*_*tic 2 angularjs angular-ng-if ng-hide

我想隐藏一个div取决于我在json中的值

例如,我有{{product.currency}},值可以是:£或€如果值相等€我想隐藏这个元素.

cha*_*tfl 6

相当简单ng-hide或相反ng-show或在页面使用中没有它ng-if

<div ng-hide="product.currency =='€'" >
 <!-- or -->
<div ng-show="product.currency !='€'" >
 <!-- or -->
<div ng-if="product.currency !='€'" > 
Run Code Online (Sandbox Code Playgroud)

而另一种选择,不是优雅或有效的ng-switch.

非常值得花一些时间查看API参考文档左侧菜单中显示的所有核心指令.