【发布时间】:2018-08-23 08:47:26
【问题描述】:
[(ngModel)] 在表单标签内不起作用
当我使用多选外部表单标签时,可以正常选择全部和 取消选择所有功能
但是当我将它放入表单时,它可以选择所有值
<form [formGroup]="roleForm">
<mat-form-field class="example-full-width">
<mat-select placeholder="Select Role Type" formControlName="roleType" (selectionChange)="roleTypeSelect($event.value)">
<mat-option *ngFor="let role of roleTypeList" [value]="role.roleTypeId">
{{role.roleTypeName}}
</mat-option>
</mat-select>
</mat-form-field> <!-- Multi Select Mat Start -->
<mat-form-field class="example-full-width">
<mat-select placeholder="Select Privileges" class="filter-select" [formControl]="selectedItems" [compareWith]="equals" multiple
#privilegeSelect="ngModel">
<mat-option disabled="disabled" class="filter-option">
<button mat-raised-button class="mat-primary fill text-sm" (click)="selectAll(privilegeSelect, dropdownList)">
Select All
</button>
<button mat-raised-button class="mat-primary fill text-sm eta-margin-all" (click)="deselectAll(privilegeSelect)">
Deselect All
</button>
</mat-option>
<mat-option *ngFor="let privilege of dropdownList" [value]="privilege">{{privilege.itemName}}</mat-option>
</mat-select>
</mat-form-field>
<!-- Multi select mat end -->
</form>
【问题讨论】:
-
感谢 Krishna Rathore
标签: angular angularjs-directive angular-material multi-select