【问题标题】:How to make ng-multiselect-dropdown a required field?如何使 ng-multiselect-dropdown 成为必填字段?
【发布时间】:2018-10-04 03:48:05
【问题描述】:

我需要使我的多选下拉菜单成为必需。任何需要下拉菜单的属性?

这是我所拥有的:

 <ng-multiselect-dropdown [placeholder]="'Select multiple mask.'"
                                                 [data]="dropdownList"
                                                 [(ngModel)]="selectedItems"
                                                 [settings]="dropdownSettings"
                                                 (onSelect)="onItemSelect($event)"
                                                 (onSelectAll)="onSelectAll($event)"
                                                 [ngModelOptions]="{standalone: true}"
                                                 id="multipleSelectId"
                                                 >
                        </ng-multiselect-dropdown>

当我单击它提交的提交按钮时。我尝试添加 ng-required 和 required 属性。它们都不起作用。

【问题讨论】:

标签: angular dropdown multiple-select


【解决方案1】:

制作一个与多选相同模型的隐藏输入元素

<div ng-dropdown-multiselect options="ctrl.list" selected-model="ctrl.item"></div>
<input type="hidden" ng-model="ctrl.item[0]" ng-required="true">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-15
    • 2018-04-26
    相关资源
    最近更新 更多