角度材料下拉列表没有以工厂形式以动态形式显示所选值

时间:2019-06-03 05:56:52

标签: angular7 dynamic-forms angular-material-7

我正在使用角度为7的动态表单。 当我尝试将选定的值传递给下拉组件时,则材质下拉列表不会显示选定的值。确实存在该值,因为我在调试后检查了它,并在搜索功能上正确地传递了该值。 但是,该值未在下拉列表中显示为预选值。 如果我尝试手动选择任何其他值,那么它将正常显示。

这是我使用了下拉菜单的下拉菜单组件中的代码:

<mat-form-field> <mat-label >{{ model.label}}</mat-label> <mat-select [(value)] = "model.value" [formControlName]="model.key" [placeholder]="model.placeholder" [disabled]="model.disabled" (onChange)="onChange.emit($event)" (onInput)="onInput.emit($event)" (onFocus)="onFocus.emit($event)" (onBlur)="onBlur.emit($event)" [(ngModel)]="model.value" [value] = "1"> <mat-option *ngFor="let option of model.options" [value]="option.value">{{option.label}} </mat-option> </mat-select> </mat-form-field>

这是我实际的父ts文件的摘录部分,在该文件中,我使用了动态表单并使用了formfactory:

this.practiceDropdown= new Dropdown({ key: "practiceId", label: "Practice", });

请注意,如果我在下拉组件中使用Primeng下拉列表而不是有角材质下拉列表,则该下拉列表可以正常工作。

<p-dropdown [options]="options" [placeholder]="model.placeholder" [disabled]="model.disabled" [autoWidth]="false" (onChange)="onChange.emit($event)" (onInput)="onInput.emit($event)" (onFocus)="onFocus.emit($event)" (onBlur)="onBlur.emit($event)" [formControlName]="model.key" ></p-dropdown>

我已经对角形材料here创建了一个请求

在将所选值传递给下拉组件时,该值应显示在下拉列表中。该值确实存在,但未显示相应的标签。手动更改标签时,标签会正确显示。

任何线索都将不胜感激。 谢谢。

0 个答案:

没有答案