I would like to use AngularJs and Select2 v4.03 without adding any directives. I've researched that it's possible now with the new version of select2
.
For now I've been using ui-select
but it's only supporting the old version of select2
and I'd like to use the new select2
features in my application.
Can anyone please help me how is it possible to use select2
with AngularJS directly (maybe via ng-model
)?
Select2
is a jQuery plugin which has a completely different approach than AngularJS native widgets (in angular these are directives) which are designed to work the angular-way from the beginning. So normally it is a good idea to use native directives if you can. If you don't find a good replacement, then you also can use jQuery elements, but you have to wrap them in an angular directive to tweak them and make them work the angular-way. This is what projects like ui-select
do.
So if the newer select2
is still not available on ui-select
you can wait until it is implemented. Or search for another wrapper... Or, search for a native alternative. If you haven't already I would recommend you to take a look at oi-select, for example, which I find quite good and flexible.
Update
Sorry, I just checked, and the select2
implementation from ui-select is a native angularJS implementation of the jQuery version and not just a wrapper.