【发布时间】:2014-03-14 08:20:33
【问题描述】:
我在这里一直使用 type ahead 指令,效果很好: http://angular-ui.github.io/bootstrap/#/typeahead
我的问题是,我已经脱离了使用整个对象的场景:
<input type="text" ng-model="MyPerson" typeahead="i as i.Name for i in PeopleSearch($viewValue)" />
到我只想要部分对象的场景:
<input type="text" ng-model="MyPerson" typeahead="i.Id as i.Name for i in PeopleSearch($viewValue)" />
此时,无论为“as”输入什么内容,模型和文本框都将包含相同的内容。谁能解释为什么会这样?看起来逻辑应该模仿 ng-options 的表达式,但显然情况并非如此。
这是一个演示:http://plnkr.co/edit/5oqlldC3PltnrynqhnAU?p=preview
选择项目后,文本框应包含此人的姓名。
【问题讨论】:
标签: angularjs angular-ui-bootstrap typeahead