Angular UI 选择不显示

2024-01-22

我目前正在使用 ui-select (https://github.com/angular-ui/ui-select https://github.com/angular-ui/ui-select) 用于下拉菜单。我已将 select.js 和 select.css 包含在我的 index.html 文件中。我还通过凉亭安装了角度消毒。

这就是我的控制器的样子:

use strict';

angular.module('myApp.home', [  'ui.select',     'ngSanitize']).controller('ScheduleCtrl', ScheduleCtrl);
ScheduleCtrl['$inject'] = [ '$stateParams', '$state' ];
function ScheduleCtrl($stateParams, $state) {
    var vm=this;

    vm.itemArray = [
                    {id: 1, name: 'first'},
                    {id: 2, name: 'second'},
                    {id: 3, name: 'third'},
                    {id: 4, name: 'fourth'},
                    {id: 5, name: 'fifth'},
                ];

    vm.scheduleEvents = [{
        id:1,
        name:'Event1'
    },
    {
        id:2,
        name:'Event2'
    }];

}

我的观点包含:

<ui-select ng-model="selectedItem">
    <ui-select-match>
        <span ng-bind="$select.selected.name"></span>
    </ui-select-match>
    <ui-select-choices repeat="item in (vm.itemArray | filter: $select.search) track by item.id">
        <span ng-bind="item.name"></span>
    </ui-select-choices>
</ui-select>

但是,我的视图是空白的,它似乎没有命中 ui-select 指令。


Remove ( and ).

<ui-select-choices repeat="item in vm.itemArray | filter: $select.search track by item.id">
    <span ng-bind="item.name"></span>
</ui-select-choices>

请参阅运行于plunker http://plnkr.co/edit/vVwyKDxRJ6ZprcfV8XrO?p=preview.

您可以测试的另一件事是,注释这一行:

//ScheduleCtrl['$inject'] = [ '$stateParams', '$state' ];

我不明白它在做什么,但是有了它,plunker 上的例子就不起作用了。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Angular UI 选择不显示 的相关文章