问题
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