Display pre-selected items in angular selectize menu?

我怕爱的太早我们不能终老 提交于 2019-12-24 03:22:42

问题


I have a selectize-ng input in my app:

<input type="text" selectize="usersSelect.options" options="users" ng-model="users.selected" />

My controller is

    $scope.users = [];

UsersWithRolesFactory.getUserRoleData().then(function(response) {
  $scope.users = response;
});

$scope.usersSelect = {
  options: {
    valueField: 'full_name',
    labelField: 'full_name',
    searchField: ['full_name'],
    plugins: ['remove_button']
  }
};

My (partial) json data is

[{"id":17,"full_name":"Janet Willis","selected":false,"merchant":"Geba","role":"Reviewer"},
{"id":18,"full_name":"Michelle Murphy","selected":false,"merchant":"Zazio","role":"Reviewer"},
{"id":19,"full_name":"Carol Gardner","selected":true,"merchant":"Skinte","role":"User"},
{"id":20,"full_name":"Laura Wallace","selected":false,"merchant":"Yacero","role":"User"}]

What I need to do is to display the users who are selected:true in the field, such as Carole Gardner here (entered by hand in the field):

How is this done?

来源:https://stackoverflow.com/questions/29309433/display-pre-selected-items-in-angular-selectize-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!