角UI选择不显​​示 [英] Angular UI select not displaying

查看:315
本文介绍了角UI选择不显​​示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用的用户界面选择( https://github.com/angular-ui/ UI选)的下拉菜单。我已经包含在我的index.html文件select.js和select.css。通过凉亭我也安装角消毒。

I am currently using ui-select (https://github.com/angular-ui/ui-select) for dropdowns. I have included select.js and select.css in my index.html file. I have also installed angular-sanitize through bower.

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

This is what my controller looks like :

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的选择指令。

However, my view is blank and it does not seem to be hitting the ui-select directive.

推荐答案

删除

<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

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

Another thing you can test, comment this line:

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

我不明白它在做什么,但它plunker的例子​​是行不通的。

I didn't understand what it is doing, but with it the example on plunker doesn't work.

这篇关于角UI选择不显​​示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆