AngularUI - ui-select 多个值未正确显示

AngularUI - ui-select multiple value not showing properly

我有一个 angular-ui 下拉列表 multi-select 没有正确显示值。输入绑定框形成一个普通框,而不计算我的 $item 表达式。类似于:

HTML:

<ui-select 
    multiple
    ng-model ="allPlatforms.selected" >
    <ui-select-match  placeholder="Start Typing...">{{$item.allPlatforms}}</ui-select-match>
    <ui-select-choices repeat="item in (allPlatforms | filter: $select.search) track by item">
        {{item.allPlatforms}}
    </ui-select-choices>
    <ui-select-no-choice>
        Dang! Sorry bro. Couldn't find
    </ui-select-no-choice>
</ui-select>

我从服务器生成并调用了两个 JSON 文件。

PFtypes JSON 文件看起来像 {"allpftypes":["pf1", "pf2"...]}

控制器JS

$scope.name={};
$scope.allPlatforms=[];

$http.get('server.com/'+$scope.num).then(function(response){
        $scope.name = response.data;
        $scope.allPlatforms.selected = [$scope.allPlatforms[0]];
//I will want to do [$scope.allPlatforms[$scope.name.platform_name]] but I've ignored that for now;
});
$http.get('server.com/pftypes').then(function(response){
        $scope.allPlatforms = response.data.allpftypes;
    });

如果我删除 multiple 属性并进行 $select 更改,它就可以正常工作。我不确定我犯了什么可怕的错误。在 Angular 还是新手,正在学习。任何帮助将不胜感激。

刚刚意识到我已经在 allplatforms 数组中并且完全忽略了那里的要点。它应该只是 $item 而不是 $item.allplatforms.

<ui-select 
    multiple
    ng-model ="allPlatforms.selected" >
  <ui-select-match  placeholder="Start Typing...">{{$item}}</ui-select-match>
  <ui-select-choices repeat="item in (allPlatforms | filter: $select.search) track by item">
    {{item}}

     //or
    //<div ng-bind-html="item | highlight: $select.search"></div>

    </ui-select-choices>
    <ui-select-no-choice>
      Dang! Sorry bro. Couldn't find
    </ui-select-no-choice>
</ui-select>

留下这个作为答案,以防万一有人遇到类似的 ui-select- 多重问题。和平!

欢迎任何进一步的更改:)