是否有一种很好的方法可以在范围内访问userName,同时在上下文中保持id:
<select id="pendingInvites" class="selectAlternateEvens" style="width: 85%; height: 300px;" ng-options="invite.id as invite.userName for invite in PendingInviteList"
multiple value=""
ng-model="user.pendingUserName"></select>
ng-model目前解析为id,user.pendingUserName.userName也不起作用。我可以查看PendingInviteList,或者我可以使用invite.userName代替id,但是我可以通过上面的代码访问它吗?
答案 0 :(得分:0)
如果要存储用户obj,请更改
ng-options="invite.id as invite.userName for invite in PendingInviteList"
要 ng-options =“在PendingInviteList中邀请为invite.userName进行邀请” NG-模型= “用户”
如果你只有名字而不是id
ng-options="invite.userName as invite.userName for invite in
PendingInviteList"
ng-model="user.pendingUserName"