Angular 已选择 - 不要将 ng-model 绑定到整个对象
Angular Chosen - Don't bind ng-model to entire object
使用 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>
但是,我想知道如何将状态对象的名称值绑定到 ng-model?
显示的选项将仅显示状态名称,但选择后,整个状态对象将绑定到 ng-model,而不仅仅是所选名称。
任何想法都会一如既往地受到赞赏!
你可以试试这个格式
select as label for value in array
例如。 s.name as s.name for s in states
使用 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>
但是,我想知道如何将状态对象的名称值绑定到 ng-model?
显示的选项将仅显示状态名称,但选择后,整个状态对象将绑定到 ng-model,而不仅仅是所选名称。
任何想法都会一如既往地受到赞赏!
你可以试试这个格式
select as label for value in array
例如。 s.name as s.name for s in states