【问题标题】:Angular ng-if ternary operator in one span?Angular ng-if 三元运算符在一个范围内?
【发布时间】:2016-08-10 05:06:25
【问题描述】:

所以我尝试使用三元运算符将 2 个跨度组合为:

<span ng-if="customer != null">{{ customer }}</span><span ng-if="customer == null">[customer]</span>

切换只是基于表单中其他地方的输入中的 id 是否具有值。有什么建议吗?

非常感谢。

【问题讨论】:

  • 您在寻找ng-switch 吗?

标签: html angularjs forms


【解决方案1】:

你的意思是这样的:

<span>{{ (customer != null) ? customer : '[customer]' }}</span>

也可以写成:

<span>{{ customer || '[customer]' }}</span>

【讨论】:

    猜你喜欢
    • 2010-12-12
    • 2021-01-03
    • 2012-08-08
    • 1970-01-01
    • 1970-01-01
    • 2021-08-01
    • 1970-01-01
    • 2020-11-08
    • 1970-01-01
    相关资源
    最近更新 更多