以preselected价值角度NG选项按对象ID [英] angular ng-options with preselected value by object id
本文介绍了以preselected价值角度NG选项按对象ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法如下选择
可以有一个 pre-选择
俱乐部?
Is there a way the following select
can have a pre-selected
club ?
<select ng-model="c.pilot.clubIdx" ng-options="club.idx as club.name for club in c.clubs track by club.idx">
c.pilot.clubIdx = 2
c.clubs = {{IDX:1,名称:club1},{IDX:2,名称:club2}}
c.pilot.clubIdx = 2
c.clubs = { {idx: 1, name: "club1"}, {idx: 2, name: "club2"} }
在选择菜单应显示club2。
The select-menu should show "club2".
由于俱乐部都存储在一个数据库,并可以改变,我喜欢他们只保留为
引用的飞行员
。
Since the clubs are stored in a db and can be altered, I like to keep them only as references
on the pilots
.
解决:通过去掉解决了跟踪问题
SOLVED: removing track by solves the problem.
推荐答案
。喜欢的东西: $ scope.c.pilot.clubIdx = 2
或 $ scope.c.pilot.clubIdx = $ scope.c.clubs [1 ] .IDX
这篇关于以preselected价值角度NG选项按对象ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文