Angular UI / select2 multiple how to preselect values/options?


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>

Where and how should I preselect options? By default selected option is only first.Somehow in controller?

Problem courtesy of: Jakub Kuchar


For a simple <select> list it's easy:

MyController function($scope) {
$ = {
categories: 'close'

For <input> it gets trickier because you may need to add a initSelection option

Solution courtesy of: ProLoser

View additional discussion.