use*_*607 3 autocomplete setvalue angular-material angular angular-reactive-forms
编辑:用 Jojofoulk 的评论解决。
当使用 angular-material 的自动完成组件时,我试图使用setValue
输入表单,但它的[matAutocomplete]
属性阻止setValue
在输入中显示。
检查反应式控件会发现该值是正确的,删除[matAutocomplete]
它可以使其工作,但它只是没有显示出来。
<mat-list-item role="listitem" *ngFor="let skill of curObj.skills;index as ind">
<div>
<mat-form-field>
<input type="text" placeholder="choose skill" aria-label="Number" matInput [formControl]="skill.control" [matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn" (optionSelected)="optSel($event.option.value,skill)">
<mat-option *ngFor="let option of skill.filteredOptions | async" [value]="option">
{{option.name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</div>
</mat-list-item>
Run Code Online (Sandbox Code Playgroud)
skill.control.setValue("some new value");
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1797 次 |
最近记录: |