Angular Bootstrap Ui-select
Asked Answered
A

5

9

I am trying to use the ui-select directive in my angularjs but it is not displaying, i tried following the documentation and this is what i did:

 <ui-select ng-model="form.gender" theme="bootstrap">
    <ui-select-choices repeat="gender in genders">
        {{ gender.name }}
    </ui-select-choices>
</ui-select>

Then I have an array of genders:

$scope.genders = [
    {
        name: 'Male'
    },
    {
        name: 'Female'
    }
];

I haven't really used this directive before so I'm a bit confused as to what i am doing wrong.

There are no errors being displayed in my browser console, i have included the module in my app as well.

I want to use it for more than a simple dropdown of genders but i figure this is a start if i can do this then i won't have any more problems. :)

Edit: So i cleared my browser cache and refreshed my page and this time i did notice an error:

Error: [ui.select:transcluded] Expected 1 .ui-select-match but got '0'.
Alignment answered 16/9, 2015 at 9:14 Comment(0)
W
1

You must visit this link and follow its examples.

You can follow its examples

I personally prefer to use uiselect2, its more powerful and simple than uiselect

link of uiselect2

Whenas answered 16/9, 2015 at 9:26 Comment(4)
I followed the link and saw what i did wrong however even after reading what they had there i am still clueless as to how the ui-select and ui-select-match and ui-select-choices work or what those directives even do.Alignment
Also when i try to use the 'selecticize' them i get errors: prntscr.com/8gx7axAlignment
I personally prefer to use uiselect2, its so simple and powerfull than uiselect link, if you got your answer , please mark it as answer :)Whenas
ui-select2 has been deprecated in favor of ui-select for quite some time. Not sure why you are recommending it.Erek
D
6

just add a class named as the tag.

 <ui-select ng-model="form.gender" theme="bootstrap">
    <ui-select-choices class="ui-select-choices" repeat="gender in genders">
        {{ gender.name }}
    </ui-select-choices>
</ui-select>
Dihydric answered 28/3, 2016 at 11:49 Comment(2)
adding ui-select-match is also required in case you are using itDramatic
Worked for me. Problem was with class, has to be the same as derective.Annoyance
C
3

Error: [ui.select:transcluded] Expected 1 .ui-select-match but got '0'.

This error was fixed recently at Github page. Just update ui-select to v0.14.3.

Reference: https://github.com/angular-ui/ui-select/issues/224

Castellan answered 2/3, 2016 at 16:15 Comment(0)
W
1

You must visit this link and follow its examples.

You can follow its examples

I personally prefer to use uiselect2, its more powerful and simple than uiselect

link of uiselect2

Whenas answered 16/9, 2015 at 9:26 Comment(4)
I followed the link and saw what i did wrong however even after reading what they had there i am still clueless as to how the ui-select and ui-select-match and ui-select-choices work or what those directives even do.Alignment
Also when i try to use the 'selecticize' them i get errors: prntscr.com/8gx7axAlignment
I personally prefer to use uiselect2, its so simple and powerfull than uiselect link, if you got your answer , please mark it as answer :)Whenas
ui-select2 has been deprecated in favor of ui-select for quite some time. Not sure why you are recommending it.Erek
U
0

.ui-select-toggle > .caret { pointer-events: none } fixes the problem of error: [ui.select:transcluded] Expected 1 .ui-select-match but got '0'. for me

Undersexed answered 9/12, 2016 at 10:10 Comment(0)
K
0

As @Caner Çakmak said, I added a class named as tag in both ui-select-choices and ui-select-match

Ex:

<ui-select ng-model="form.gender" theme="bootstrap">
    <ui-select-match class="ui-select-match" [etc...etc....etc]>
    <ui-select-choices class="ui-select-choices" repeat="gender in genders">
    {{ gender.name }}
    </ui-select-choices>
</ui-select>

And it worked! Thanks

PS: I am using ui-select v0.19.X and Angular v1.5.X (that seems to be when this error occurs)

Keratoplasty answered 27/4, 2017 at 14:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.