【问题标题】:How to use ternary in ng-init in AngularJS? [duplicate]如何在 AngularJS 的 ng-init 中使用三元? [复制]
【发布时间】:2014-09-16 04:39:44
【问题描述】:

AngularJS 中ng-init 可以使用三元运算符吗?

类似:<select ng-model="project" name="act" ng-options="act.user_id as act.user_display_name for act in actors" ng-init="isLoggedIn == true ? "" : act.user_id = credentials.user_id" ></select>

【问题讨论】:

    标签: javascript angularjs angularjs-scope


    【解决方案1】:

    是的,这是可能的。这是一个非常简单的演示:

    http://jsbin.com/wobayovi/1/edit?html,output

    【讨论】:

    • 嘿@bencripps,谢谢。似乎工作:) 但很敏感吧?什么意思(真 === 真)?
    • 哈哈我没有任何意思——我只是想要一个非常简单的演示。 True 将始终评估为 true,您可以将三元表达式更改为您喜欢的任何内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-12
    • 1970-01-01
    • 1970-01-01
    • 2019-01-24
    相关资源
    最近更新 更多