Angular 5中的ng-multiselect-dropdown的验证

时间:2019-05-28 15:26:56

标签: angular

我使用此npm“ ng-multiselect-dropdown”在应用程序中使用多选下拉列表。我想为此多重选择(模板驱动的表单)创建验证

ng-multiselect-dropdown

有人建议我如何进行验证吗?

2 个答案:

答案 0 :(得分:0)

html

<ng-multiselect-dropdown
[ngClass]="{'is-invalid': address.controls['district'].status==='INVALID'}"
style="padding: 0;"
formControlName="district"
>
</ng-multiselect-dropdown>

type script

district: ["", Validators.required],

答案 1 :(得分:0)

html

<ng-multiselect-dropdown 
        formControlName="vendorList" id="vendorList" [data]="vendorNameList"
        [(ngModel)]="selectedVendor" [settings]="vendorListDropdownSettings"
        >
    </ng-multiselect-dropdown>
<div *ngIf="submitted && formGroup.controls['vendorList'].invalid" 
        class="text-danger mt-1">
      <div *ngIf="formGroup.controls['vendorList'].errors.required">
        Vendor Name is required.
      </div>
    </div>

打字稿

vendorList: ["", Validators.required],