【发布时间】:2018-01-10 11:39:30
【问题描述】:
目前我有多个下拉指令共享相同的下拉值数组。当我进行选择时,它会更新其余的下拉列表选择值,以及如何为我的其余下拉列表提供唯一选择。
我目前的工作是设置ng-model="ctrl.ngModel",但是我将无法访问下拉选择的值。
dropdown.html
<div>
<ui-select name='' ng-model="ctrl.ngModel.selected" theme="bootstrap" class='expiry admin-expiry'
append-to-body='true'
reset-search-input='true'
on-select="ctrl.update()">
<ui-select-match placeholder="">{{$select.selected.value}}</ui-select-match>
<ui-select-choices repeat="choice in ctrl.choices | filter: $select.search"
position='down'>
<span ng-bind-html="ctrl.trustAsHtml(choice.value)"></span>
</ui-select-choices>
</ui-select>
</div>
controller.js
function ColDropdownDirective() {
return {
restrict: 'EA',
scope: {
ngModel: '=',
choices: '='
},
controller: ['FxoUtils', function(_) {
var ctrl = this;
this.trustAsHtml = function(value) {
return _.trustAsHtml(value);
};
this.update = function() {
console.log(ctrl.ngModel.selected);
};
}],
controllerAs: 'ctrl',
bindToController: true,
templateUrl: 'js/fxo/admin/thresholdconfig/common/common.col.dropdown.html'
};
}
【问题讨论】:
标签: javascript angularjs drop-down-menu ui-select