【问题标题】:Angular translate pipe in condition角平移管条件
【发布时间】:2021-03-19 08:07:30
【问题描述】:

我正在尝试在模板中为翻译设置条件,像这样

{{showBigMap ? 'Shared.ShowMap' | translate : 'Shared.HideMap' | translate }}

但它没有编译,出现错误,我的问题是如何在角度组件模板中使用 translate in condition?

【问题讨论】:

    标签: angular translate


    【解决方案1】:
    {{showBigMap ? ('Shared.ShowMap' | translate ): ('Shared.HideMap' | translate) }}
    

    用括号括起来

    【讨论】:

      【解决方案2】:

      我建议你以更易读的方式编写它:

      {{ (showBigMap ? 'Shared.ShowMap' : 'Shared.HideMap') | translate }}
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-11-29
        相关资源
        最近更新 更多