You can pass an object to Select2 as the expression: ui-select2="{allowClear:true}"
that will be passed directly to $.fn.select2()
. You can read more about the supported list of options and what they do on the Select2 Documentation Page. AngularUI will leverage properties passed to Select2 for any complex behavior, there are no parameters necessary for that are specific to AngularUI.
ui-select2
is incompatible with <select ng-options>
. For the best results use <option ng-repeat>
instead
In order to properly support the Select2 placeholder, create an empty <option>
tag at the top of the <select>
and either set a data-placeholder
on the select element or pass a placeholder
option to Select2.
<p>Value is: {{select2}} <a ng-click="select2='two'">(choose second)</a></p> <select ui-select2 ng-model="select2"> <option value="">Pick a number</option> <option value="one">First</option> <option value="two">Second</option> <option value="three">Third</option> </select>
Or try playing around with this sandbox demo to see how AJAX works