gpt4 book ai didi

javascript - Angular Chosen - 不要将 ng-model 绑定(bind)到整个对象

转载 作者:行者123 更新时间:2023-11-27 23:44:04 25 4
gpt4 key购买 nike

使用 Angular 选择

https://github.com/localytics/angular-chosen

并测试以下示例

<select multiple
chosen
ng-model="state"
ng-options="s.name for s in states">
<option value=""></option>
</select>

但是,我想知道如何将状态对象的名称值绑定(bind)到 ng-model?

提供的选项将仅显示状态名称,但选择后,整个状态对象将绑定(bind)到 ng-model 而不仅仅是所选名称。

任何想法都会一如既往地受到重视!

最佳答案

您可以尝试这种格式

select as label for value in array
例如。 s.name 作为各州 s 的 s.name

关于javascript - Angular Chosen - 不要将 ng-model 绑定(bind)到整个对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33398426/

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