-
Notifications
You must be signed in to change notification settings - Fork 1.8k
ui-select broken with angular 1.5.0 beta2 #1325
Comments
Is this related with #1128? |
It seems not |
In what is it broken? Updating the examples to use http://plnkr.co/edit/4EsCcN8z3OZKYM1qjp84?p=preview |
Ok you are right, with 1.4.8 is working, only with 1.5.0 beta2 I get the following error:
The problem if you use this library for production is that it seems to have been quite abandoned from the maintaners... I regret to have chosen this library for my project due to the lack of support (that's why also I'm lazy to report broken stuff in the proper way, since nobody seems to really care about it) |
@LeleDev Thanks for your feedback. I hope to find some good alternatives without messing around with $apply. Please let me know if you know about some of them :-) |
You could give a try to the old ui-select directive repository code (when it was a wrapper for the nice select2 library: https://github.com/select2/select2) at this page: https://github.com/angular-ui/ui-select2/blob/master/src/select2.js Unluckily there aren't many good alternative to ui-select that work out of the box... so I'm afraid that you will have to gamble and stick to this one, hoping that some new maintainers will be assigned to the project from the angular-ui team... |
It seems to have been caused by this change for 1.5.0-beta.1 Lazily compile the You can prove it by setting eager=true in the debugger. |
Moderator note:This workaround should no longer be required in ui-select v0.14.3+ The workaround is really simple. Add class to ui-select-match and ui-select-choices with the same name See the diff @ inetsys/ng-formalizer@e186302 |
Nice one! Works for me. |
@llafuente It works, but WHY? |
Select2 theme does not works (it does not show the search icon etc.) |
I have the same problem with |
@llafuente Thanks for the easy workaround. Works for me with |
Thanks @llafuente, Works for me with |
Hi, just checking if there are any plans to resolve within ui-select without using the work-around described above, as the Angular issue has been moved to the Ice Box. |
@llafuente Thanks for the easy/crazy workaround. Works for me with angular-1.5.0-rc.0. |
Had difficulties getting bootstrap theme to work with angular-1.5.0-rc.0 . Finally got it. Here's a working Plunker if others still have problems. |
+1 here |
The workaround from @llafuente still works with the 1.5.0. Thanks for sharing! |
Thanks man, works great with 1.5. |
@avgalon it works because part of the compilation process takes elements called I had been debugging this last night and I thought it was because I had moved these into templates that were loaded asynchronously (there are other bugs in this project for the same thing which give the same error message). Then I realized that I had upgraded my Angular version as well (to 1.5.0), which is actually what caused it. So I can confirm this also works on 1.5.0. |
I'm trying to override select directives so that these classes are automatically added as a part of the compilation process, rather than me adding all the classes manually in the html. No luck for the time being :( |
@llafuente thanks a lot, this little magic worked :) |
Here's my fix so that you don't have to manually add classes everywhere, since this will add them automatically.
|
Um, setting a class on an element is a workaround, not a fix. The problem is that ui-select reaches into the transcluded content before it has been compiled. It should instead wait until the transcluded content is ready. The children should require the ui-select directive and call a function in the ui-select controller when they have been linked successfully. At least that's how I would do it. |
The diff by @llafuente solved it in my case. |
@llafuente Thanks for the solution works for me with angular 1.5.0. |
@misaizdaleka where did you put that to get it to work? I have a ton of selects throughout a platform I'm working on, and adding classes is unreasonable |
In Angular 1.5, transcluded content is linked lazily. For uiSelect that means the clone in the transclude function is not compiled and linked yet, so uiSelect cannot detect the match and choices elements by their classnames, because they haven't been set yet (which happens by replacing the elements with the templates). However, the templateUrl function is executed at this point, so we can use it to add the class names to the directive elements. On another note, this behavior also affected versions earlier than 1.5.0-beta.2, when the template of ui-select-match or ui-select-choices wasn't cached. In that case, the async compilation of the template would mean also that the clone in the transclude function wasn't compiled yet, and so the classes wouldn't be set either. Closes angular-ui#1422 Closes angular-ui#1356 Closes angular-ui#1325 Closes angular-ui#1239
In Angular 1.5, transcluded content is compiled lazily. For uiSelect that means the clone in the transclude function is not compiled and linked yet, so uiSelect cannot detect the match and choices elements by their classnames, because they haven't been set yet (which happens by replacing the elements with the templates). However, the templateUrl function is executed at this point, so we can use it to add the class names to the directive elements. On another note, this behavior also affected versions earlier than 1.5.0-beta.2, when the template of ui-select-match or ui-select-choices wasn't cached. In that case, the async compilation of the template would mean also that the clone in the transclude function wasn't compiled yet, and so the classes wouldn't be set either. This might be the cause of the error described in issue angular-ui#224. Closes angular-ui#1422 Closes angular-ui#1356 Closes angular-ui#1325 Closes angular-ui#1239
@llafuente, I spent a lot of time searching for solution and got nothing. But your post save a lot of my time. Thx a lot, man) |
@joshjwalker just put in your main js file. In my case, it was app.js. |
The fix has been published in v0.14.3. |
Thanks @aaronroberson and @Narretz! |
@llafuente Thanks for the solution! It works for me with angular 1.5.0. |
@llafuente Thanks, it works for me with Angualr 1.5.0. But I want to know why it works when I add the class to ui-select-match and ui-select-choices with the same name. can you tell me ? Thanks a lot! |
@Just-Rookie Its a workaround not a solution (the solution is update to ui-select > v0.14.3) See PR #1430 for details on why adding classes work. |
@user378230 Thanks! |
In case someone really knows what the heck I'm doing wrong please share...This does not work. ui-select.form-control(multiple ng-model="searchFilters.someProperty")
ui-select-match(placeholder="{{::'Choose...' | translate}}") {{$item.text | translate}}
ui-select-choices(repeat="filterOption.value as filterOption in searchFilters.someList track by filterOption.value")
span {{filterOption.text | translate}}
All I get is Thx |
@crissdev posting in closed issues is not the best way to get attention to your issue |
you're right not so cool writing on closed issues. but any of the solutions included in this thread worked for me :(, so I ended up downgrading the ui-select2 version:
and it's working now |
@heridev did you see my reply? #1325 (comment) |
Expected 1 .ui-select-match but got '0'. angular-ui/ui-select#1325 (comment)
@llafuente nice work my friend! very simple! |
Thank you @llafuente |
Hi All, |
Ui-select doesn't work with latest angularjs updates
The text was updated successfully, but these errors were encountered: