Javascript ui选择2所选值不变-angularjs
我正在使用ui.select2作为下拉列表 场景 我有一个返回下拉值的ajax调用Javascript ui选择2所选值不变-angularjs,javascript,angularjs,ui-select2,Javascript,Angularjs,Ui Select2,我正在使用ui.select2作为下拉列表 场景 我有一个返回下拉值的ajax调用 document.dropDownDocStatuses = [ { key: 0, value: 'All active (' + response.totalDocuments + ')' }, { key: 1, value: 'Draft (' + response.draft + ')' } ]; 在html中,我
document.dropDownDocStatuses = [
{ key: 0, value: 'All active (' + response.totalDocuments + ')' },
{ key: 1, value: 'Draft (' + response.draft + ')' }
];
在html中,我有
<select ui-select2 class="form-control font-12px input-style3 "
ng-model="document.dropDownDocStatus"
ng-change="document.filterDocuments()">
<option ng-repeat="documents in document.dropDownDocStatuses" value="{{documents.key}}">({{documents.value}})</option> </select>
数值会被更新,但它不会改变所选数值文本,而如果我点击下拉菜单,我会在下拉菜单中改变数值
有人能告诉我如何解决这个问题吗?如果有任何帮助,我们将不胜感激。我刚刚遇到了与您相同的问题,根本原因是ng模型字段,您不应该使用“选项”字段存储ng模型,尝试为ng模型创建另一个字段,您将能够选择值 e、 g 和HTML格式:
<select ui-select2 class="form-control font-12px input-style3 "
ng-model="document.selectedDocStatus"
ng-change="document.filterDocuments()">
<option ng-repeat="documents in document.dropDownDocStatuses" value="{{documents.key}}">({{documents.value}})</option> </select>
({{documents.value}})
然后您应该能够成功地选择该值
document.dropDownDocStatuses = [
{ key: 0, value: 'All active (' + response.totalDocuments + ')' },
{ key: 1, value: 'Draft (' + response.draft + ')' }
];
document.selectedDocStatus = [];
<select ui-select2 class="form-control font-12px input-style3 "
ng-model="document.selectedDocStatus"
ng-change="document.filterDocuments()">
<option ng-repeat="documents in document.dropDownDocStatuses" value="{{documents.key}}">({{documents.value}})</option> </select>