Angular ui-select 模型绑定

Angular ui-select model binding

我在范围内有以下对象

$scope.myData = {};
$scope.companies =    [{name:'Microsoft',slug:'micro'},
                {name:'Google',slug:'gg'}];

我正在尝试 bing 使用 ui-select

进行建模
<div class="form-group">
  <label>Company</label>
    <ui-select ng-model="$parent.myData.company" theme="bootstrap">
    <ui-select-match placeholder="Select or search a company in the list...">{{$select.selected.name}}</ui-select-match>
    <ui-select-choices repeat="company in companies | filter: $select.search">
    <div ng-bind-html="company.name | highlight: $select.search"></div>
    </ui-select-choices>
    </ui-select>
</div>

然而当我select一家公司时,myData.company变成了满对象如。 {"name":"Microsoft","slug":"micro"} 如何将公司对象的 slug 绑定到 myData.company 但能够按公司名称搜索?

感谢this,我终于找到了解决方法 为了让它工作,<ui-select-choices> 应该改变如下;

<ui-select-choices repeat="company.slug as company in companies | filter: $select.search">