我在我的应用程序中使用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'
};
以下解决方案适合我。我添加了设置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>