3

I'm using angular-ui and bootstrap in the same web application and I've an issue when trying to use the ui-select2 component: everything works fine except that upon selecting an element in the drop-down list it's not shown in the component, it shows empty, though the ng-model associated variable is correctly updated. This strange behavior goes away if I remove the inclusion of the bootstrap.js file from the main page. Is there anyone who has experienced using both angular-js and bootstrap at the same time and/or who knows about any tweaks to apply for having them work together?

UPDATE:

The ui-select2 component is inside an input-append div, just removing the div solves the problem. I've created a fork of the Angular-ui ui-select2 original sandbox demo here. You can go to the "Version 2" example and check that selecting a value in the list correctly update the model but doesn't updates the input element.

3
  • I've just discovered that the issue is caused by the select2 component being inside an input-append div, just removing the div solves the problem. Anyway the question is still valid, I've just narrowed the way, seems that it's some css clash. Commented Jan 14, 2013 at 10:53
  • Can you create a fiddle or something to demonstrate the code and behavior? Commented Jan 15, 2013 at 0:17
  • @ProLoser Thanks for your interest, I've updated my question with a link to an example. Commented Jan 15, 2013 at 8:06

1 Answer 1

6

The bottom line is that you cannot use input-append alongside Select2 natively. The input that you put into the HTML is actually going to be hidden, and Select2 injects additional DOM elements (divs, lists and inputs) that all will be hidden/shown and all have their own respective CSS.

The problem you are having is due to conflicting CSS between Bootstrap and Select2.

You should consider A: Not using input-append, B: Rewriting or tweaking the CSS to un-hide the relevant elements, C: Use typeahead or some other solution that plays nicely with Bootstrap's CSS instead.

You can checkout the AngularUI Bootstrap Project or check out this Plunker / Gist that shows you how to run Bootstrap directives using the AngularUI Passthrough directive.

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

1 Comment

Thanks a lot for your help, I'll go with the solution shown in your Plunker. By the way, I've seen your are the author of "AngularJS Tips and Tricks", great job!

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.