Angular UI 选择不显示 [英] Angular UI select not displaying
问题描述
我目前正在使用 ui-select (https://github.com/angular-ui/ui-select) 用于下拉菜单.我在 index.html 文件中包含了 select.js 和 select.css.我还通过凉亭安装了 angular-sanitize.
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-select 指令.
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.
这篇关于Angular UI 选择不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!