Angular 调用formControl setValue可取消选择mat芯片列表
我有一个mat芯片列表输入字段。芯片为Angular 调用formControl setValue可取消选择mat芯片列表,angular,angular-material,Angular,Angular Material,我有一个mat芯片列表输入字段。芯片为选定的样式。我注意到,每当我调用字段表单控件的setValue()one时,芯片都是未选择的。有什么办法防止这种行为吗 之前: 之后: 指定实体 {{entityId} 取消 {{entityInfo.entityName} 我面临着完全相同的问题。可能是因为所选选项的类型是object而不是string。我面临着完全相同的问题。可能是因为所选选项的类型为object而不是string。 <mat-form-field appearance="o
选定的样式。我注意到,每当我调用字段表单控件的setValue()
one时,芯片都是未选择的。有什么办法防止这种行为吗
之前:
之后:
指定实体
{{entityId}
取消
{{entityInfo.entityName}
我面临着完全相同的问题。可能是因为所选选项的类型是object而不是string。我面临着完全相同的问题。可能是因为所选选项的类型为object而不是string。
<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>