Angular UI / select2 multiple How to pre-select values ​​/ parameters?

using angular -ui with select2 as follows:

<select ui-select2 ng-model="search.categories" multiple style="width:300px" data-placeholder="select category"> <option value="open" >open</option> <option value="close" >close</option> </select> 

Where and how should you choose options? By default, the selected option is only the first. Somehow in the controller?

+4
source share
1 answer

For a simple <select> list, this is easy:

 MyController function($scope) { $scope.search = { categories: 'close' }; } 

For <input> this gets harder because you might need to add the initSelection parameter

+2
source

All Articles