Angular select2 directive allows you to enhance your select elements with behaviour from the select2 library.
All about the famous library select2 by @ivaynberg adapted as a directive for angular.
This directive allows you to enhance your select elements with behaviour from the select2 library.
Usage
AngularJS wrapper for select2 (deprecated)
Instead, use angular-ui/ui-select
Add the select2
module as a dependency to your application module:
var myAppModule = angular.module('MyApp', ['ui.select2']);
Apply the directive to your form elements:
<select ui-select2 ng-model="select2" data-placeholder="Pick a number">
<option value=""></option>
<option value="one">First</option>
<option value="two">Second</option>
<option value="three">Third</option>
</select>
The ui-select2
directive plays nicely with ng-model and validation directives such as ng-required.
If you add the ng-model
directive to same the element as ui-select2
then the picked option is automatically synchronized with the model value.