eri*_*n30 6 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'
}];
}
Run Code Online (Sandbox Code Playgroud)
我的观点包含:
<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>
Run Code Online (Sandbox Code Playgroud)
但是,我的视图是空白的,它似乎没有达到ui-select指令.
删除(和)。
<ui-select-choices repeat="item in vm.itemArray | filter: $select.search track by item.id">
<span ng-bind="item.name"></span>
</ui-select-choices>
Run Code Online (Sandbox Code Playgroud)
请参阅在plunker上运行。
您可以测试的另一件事是,注释这一行:
//ScheduleCtrl['$inject'] = [ '$stateParams', '$state' ];
Run Code Online (Sandbox Code Playgroud)
我不明白它在做什么,但是有了它,关于 plunker 的例子就不起作用了。
| 归档时间: |
|
| 查看次数: |
1465 次 |
| 最近记录: |