gpt4 book ai didi

javascript - 如何在 angular.js 中使用 ng-model 获取按钮文本?

转载 作者:行者123 更新时间:2023-11-30 12:30:36 25 4
gpt4 key购买 nike

我刚开始使用 Angular,实现起来似乎不错。我总是使用 ng-modeltextfield 获取文本。我可以借助 ng-model 或其他工具获取按钮文本吗?

我知道在这里问不是个好问题。但我在任何地方都没有得到任何相关的解决方案。

例如这是按钮

<button class="common btnDarkGrey">Do it</button>

我想用 Angular Do it

谢谢。

最佳答案

您应该使用 ng-bind 将 Controller 中的数据绑定(bind)到按钮。

<button ng-bind="buttonNameVariable"></button>    

然后在你的 Controller 中你将有一个名为 scope.buttonNameVariable="Do it"

的变量

您可以在 Controller 中使用变量,并通过变量检索它。您仅将 ng-model 用于 html 中的输入字段,而不用于例如按钮。

关于javascript - 如何在 angular.js 中使用 ng-model 获取按钮文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27835358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com