【问题标题】:Hide element depending on value json in Angularjs根据Angularjs中的值json隐藏元素
【发布时间】:2015-01-26 17:45:30
【问题描述】:

我想根据我在 json 中的值隐藏一个 div

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

【问题讨论】:

    标签: angularjs angular-ng-if ng-hide


    【解决方案1】:

    ng-hide 或相反的ng-show 相当简单,或者在页面中不使用它ng-if

    <div ng-hide="product.currency =='€'" >
     <!-- or -->
    <div ng-show="product.currency !='€'" >
     <!-- or -->
    <div ng-if="product.currency !='€'" > 
    

    另外一种选择是ng-switch,但不是那么优雅或高效。

    值得花点时间查看API reference docs 左侧菜单中显示的所有核心指令。

    【讨论】:

      猜你喜欢
      • 2020-07-06
      • 1970-01-01
      • 1970-01-01
      • 2014-04-22
      • 2013-10-24
      • 1970-01-01
      • 2021-12-01
      • 2015-09-01
      • 2016-10-08
      相关资源
      最近更新 更多