Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 调用formControl setValue可取消选择mat芯片列表_Angular_Angular Material - Fatal编程技术网

Angular 调用formControl setValue可取消选择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

我有一个mat芯片列表输入字段。芯片为
选定的
样式。我注意到,每当我调用字段表单控件的
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>