【问题标题】:How can I make the text of a button change in AngularJS?如何在 AngularJS 中更改按钮的文本?
【发布时间】:2015-01-05 14:18:49
【问题描述】:

我有一个 HTML 按钮:

<button>     </button>

如何根据 $scope 变量的值进行内部更改?

$scope.action == Action.Authenticating

如果它是假的,我希望它说“登录”,如果它是真的,它会说“登录...”。

【问题讨论】:

    标签: javascript angularjs


    【解决方案1】:

    您可以在绑定中使用ternary operator

    <button>{{action === "someValue" ? "Primary" : "Alternate"}}</button>
    

    【讨论】:

      【解决方案2】:

      给你:

      <button>{{action ? 'Signing in...' : 'Sign in'}}</button>
      

      【讨论】:

        猜你喜欢
        • 2017-01-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-15
        • 1970-01-01
        • 2017-12-17
        • 2011-07-31
        相关资源
        最近更新 更多