以前的值不会显示在Angular UI Select上

Previous values are not showing on Angular UI-Select

本文关键字:Angular UI Select 显示      更新时间:2023-09-26

我正在尝试使用此模块:https://github.com/angular-ui/ui-select

我正在使用多选选项。我从api中获取值,并将它们显示为选择框的选项。

但它不会显示以前选择的选项,即使当我使用console.log($scope.modalPrivacyGroups.selected)时,它最初显示的是以前选择的值,过了一段时间它就变空了!

我的HTML:

<ui-select id="privacyUsers" multiple ng-model="modalPrivacyUsers.selected" theme="bootstrap"
                           ng-disabled="disabled"
                           style="width: 100%;">
                    <ui-select-match placeholder="Select users">
                        {{$item.full_name}}
                    </ui-select-match>
                    <ui-select-choices repeat="user in allUsers | filter:$select.search">
                        {{user.full_name + ' &lt;' + user.email+ '&gt;'}}
                    </ui-select-choices>
</ui-select>

我的Angular JS代码:

var CustomPrivacyCtrl = function ($scope, $modal,  $modalInstance, Auth, User, Group) {
    $scope.modalPrivacyUsers = {};
    $scope.modalPrivacyUsers.selected = [];
    $scope.modalPrivacyGroups = {};
    $scope.modalPrivacyGroups.selected = [];
    $scope.allUsers = User.query();
    $scope.modalPrivacyUsers.selected = $scope.$parent.tweet.privacyUsers;
}

如果有人能纠正或给我一个解决方案,那就太好了

这是原始代码的简化版本,因为代码的某些部分特定于您的业务模型。[plnkr] 1