fro*_*sty 1 angularjs ui-select2
我尝试了AngularJS ui-select演示应用程序:https://github.com/angular-ui/ui-select2/tree/master/demo进行多选.我尝试的具体示例是具有预定义值的多选.最初它加载两个预选状态.单击条目时,下拉列表显示未定义.和model有两个字符的州名.我错过了什么吗?
plunker链接:http://plnkr.co/edit/IeWSZX2MDq1GfXbm3hQB
HTML:
<input type="text" style="width:300px" ui-select2="multi" ng-model="multi2Value" />
Run Code Online (Sandbox Code Playgroud)
片段:
var states = [
{ text: 'Alaskan/Hawaiian Time Zone', children: [
{ id: 'AK', text: 'Alaska' },
{ id: 'HI', text: 'Hawaii' }
]},
{ text: 'Pacific Time Zone', children: [
{ id: 'CA', text: 'California' },
{ id: 'NV', text: 'Nevada' },
{ id: 'OR', text: 'Oregon' },
{ id: 'WA', text: 'Washington' }
]}, ...}
$scope.multi2Value = [
{ id: 'CT', text: 'Connecticut' },
{ id: 'DE', text: 'Delaware' }];
$scope.multi = {
multiple: true,
query: function (query) {
query.callback({ results: states });
},
initSelection: function (element, callback) {
var val = $(element).select2('val'),
results = [];
for (var i=0; i<val.length; i++) {
results.push(findState(val[i]));
}
callback(results);
}
};
Run Code Online (Sandbox Code Playgroud)
All*_*len 13
将您的<input>字段更改为<div>并再次尝试.
html标记应如下所示:
<div style="width:300px" ui-select2="multi" ng-model="multi2Value" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17859 次 |
| 最近记录: |