我有一个mat-chip-list输入字段。筹码为selected
风格。我注意到,每当我将setValue()
称为字段表单控件时,都会取消选择筹码。有什么办法可以防止这种行为?
<mat-form-field appearance="outline" class="width-100-percent">
<mat-label>Assigned Entities</mat-label>
<mat-chip-list #entityChipList>
<mat-chip selected *ngFor="let entityId of entityIds; let idx = index"
(removed)="removeEntity(idx)">
{{entityId}}
<mat-icon matChipRemove>cancel</mat-icon>
</mat-chip>
<input #entityInput name="entity" placeholder="Add new entity" formControlName="entityInput"
[matAutocomplete]="auto"
[matChipInputFor]="entityChipList"
[matChipInputSeparatorKeyCodes]="separatorKeyCodes"
(matChipInputTokenEnd)="add($event)"/>
</mat-chip-list>
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event)">
<mat-option *ngFor="let entityInfo of filteredEntityInfos | async" [value]="entityInfo">
{{entityInfo.entityName}}
</mat-option>
</mat-autocomplete>
</mat-form-field>