4

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 I preselect options? By default selected option is only first.Somehow in controller?

1 Answer 1

2

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

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

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

Sign up to request clarification or add additional context in comments.

2 Comments

yes worked with categories: ['close','open'] ; but not with 'closed' value. Wtf? Even the auto-completer showing up "close" even closed option value='closed' was declared..
how to use initSelection in simple case when tags is array of string?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.