Angular Bootstrap Ui-select

use*_*908 8 twitter-bootstrap angularjs angular-ui-select

我试图在我的angularjs中使用ui-select指令,但它没有显示,我试着按照文档,这就是我做的:

 <ui-select ng-model="form.gender" theme="bootstrap">
    <ui-select-choices repeat="gender in genders">
        {{ gender.name }}
    </ui-select-choices>
</ui-select>
Run Code Online (Sandbox Code Playgroud)

然后我有一系列性别:

$scope.genders = [
    {
        name: 'Male'
    },
    {
        name: 'Female'
    }
];
Run Code Online (Sandbox Code Playgroud)

我以前没有真正使用过这个指令所以我对我做错了有点困惑.

我的浏览器控制台中没有显示错误,我也在我的应用程序中包含了该模块.

我想使用它不仅仅是一个简单的性别下拉,但我认为这是一个开始,如果我能做到这一点,那么我将不会有任何更多的问题.:)

编辑:所以我清除了我的浏览器缓存并刷新了我的页面,这次我确实注意到一个错误:

Error: [ui.select:transcluded] Expected 1 .ui-select-match but got '0'.
Run Code Online (Sandbox Code Playgroud)

Can*_*mak 5

只需添加一个名为标签的类。

 <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>
Run Code Online (Sandbox Code Playgroud)

  • 如果您正在使用它,还需要添加ui-select-match (2认同)

Kas*_*afa 1

您必须访问此链接并遵循其示例。

你可以按照它的例子

我个人更喜欢使用uiselect2,它比uiselect更强大而且简单

uiselect2 的链接

  • ui-select2 已被弃用一段时间,取而代之的是 ui-select。不知道你为什么推荐它。 (2认同)