【发布时间】:2014-11-26 14:12:04
【问题描述】:
我想将此 HTML 选择转换为 angular-ui/ui-select 语法:
<select ng-model="person.email" ng-options="p.email as p.name for p in people"></select>
如何使 ng-model 成为个人电子邮件? ng-options 语法(“p.email as p.name for p in people”)不适用于 ui-select repeat。
我已经设法让 ui-select 选择正确的人对象。但我只对电子邮件字段感兴趣。
<ui-select ng-model="person.email" theme="bootstrap">
<ui-select-match placeholder="Choose">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="person in people">
<div ng-bind-html="person.name | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
控制器中的人物对象:
$scope.people = [
{ name: 'Adam', email: 'adam@email.com', age: 10 },
{ name: 'Amalie', email: 'amalie@email.com', age: 12 }
];
以上代码演示:Plunker
【问题讨论】:
-
Angular chosen 更好地处理这些......并且语法也紧密对齐......
标签: javascript angularjs angular-ui