我嘗試了AngularJS ui-select應用程序:https://github.com/angular-ui/ui-select2/tree/master/demo多選。我嘗試的具體示例是使用預定義值的多選。最初它加載兩個預選狀態。點擊一個條目,下拉菜單顯示未定義。並且模型具有兩個字符的狀態名稱。我錯過了什麼嗎?AngularJS ui-select2多選不工作
plunker鏈接:http://plnkr.co/edit/IeWSZX2MDq1GfXbm3hQB
HTML:
<input type="text" style="width:300px" ui-select2="multi" ng-model="multi2Value" />
段:
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);
}
};
你可以提供一個plunker? –