0

I am trying to get select2 library working with AngularJS select.

I am created a small jsfiddle with the same option values which i am using in my project.

But the select2 seems to be working wrongly. For Eg: When I select index 2, it shows value from index 3. For the first tome it works fine, but from the second time it breaks.

JSFiddle Link

Has anyone faced this issue till now?

4
  • The event handlers added by jQuery fight the event handlers added by the AngularJS directives. Use angular-ui-select - AngularJS native version of Select2 and Selectize Commented May 20, 2018 at 14:27
  • can you please share an example of angularjs-select? Commented May 20, 2018 at 14:30
  • github.com/angular-ui/ui-select Commented May 20, 2018 at 14:31
  • I agree with @georgeawg to use angular plugins libs. But sometimes you just don't get exact same library in angular. So considering that, I've posted the working solution. You can check if it works or you can always use angular-ui set of libraries like ui-bootstrap, etc Commented May 20, 2018 at 14:34

1 Answer 1

0

You're using way too older version of angularjs. At least use 1.4.x There are many breaking changes after 1.2. So, at least from 1.4 it's quite stable. I've created following plunker example from your jsfiddle code. It's working as expected.

Plunker Example

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

2 Comments

This works. But I dont understand why @georgeawg wrote "event handlers added by jQuery fight the event handlers added by the AngularJS directives". It shouldn't have worked for 1.4 either.
@NagendraSingh What he said is correct. but angularjs doesn't have problem with jquery. They recommended not to use but if you add the lib before angularjs in index.html then angularjs itself starts using the external jquery. But very old version of angularjs has problem with recent versions of jquery.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.