Angular UI选择不显示

时间:2016-01-08 14:03:56

标签: javascript angularjs angular-ui angular-ui-select

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

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

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指令。

1 个答案:

答案 0 :(得分:1)

删除()

<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上运行。

你可以测试另一件事,评论这一行:

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

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

相关问题