如何使用ng-repeat值设置多选下拉列表的选择限制

时间:2018-09-13 02:01:37

标签: angularjs dropdown multi-select

我在我的应用中使用AngularJS Dropdown Multiselect,在示例中说我可以在角度控制器的selectionLimit内设置extra-settings,但我想要的selectionLimit具有的下拉菜单是动态的(这是一个ng-repeat值,用户可以在input框中随时更改)

下拉列表由ng-repeat生成。

<tr ng-repeat="detail in mainCtrl.lineDetails">
    <td>
        <div ng-dropdown-multiselect="true" options="mainCtrl.Customers" selected-model="detail.SelectedCustomers" extra-settings="mainCtrl.selectedCustomersSettings">
        </div>
    </td>
    <td>
        <input type="number" id="SelectionLimit" name="SelectionLimit" ng-model="detail.SelectionLimit" ng-min="0" required/>
    </td>
</tr>

设置

self.selectedCustomersSettings = {
    searchField: 'name',
    enableSearch: true,
    displayProp: 'name',
    scrollableHeight: '300px',
    scrollable: true,
    keyboardControls: true,
    idProperty: 'name',
    buttonClasses: 'form-control drpdwn-btn'
};

1 个答案:

答案 0 :(得分:0)

以下解决方案对我有用。我添加了设置inline,以便可以将selectionLimit的值设置为ng-repeat

<div ng-dropdown-multiselect="true" options="mainCtrl.Customers" selected-model="detail.SelectedCustomers" extra-settings="{searchField: 'name',enableSearch: true,displayProp: 'name',scrollableHeight: '300px',scrollable: true,keyboardControls: true,idProperty: 'name',buttonClasses: 'form-control drpdwn-btn',selectionLimit:detail.NoOfStores}" >
</div>