Angular 当用*ngIf显示时,mat select not SETING value(选择不设置值)

Angular 当用*ngIf显示时,mat select not SETING value(选择不设置值),angular,drop-down-menu,angular-ng-if,Angular,Drop Down Menu,Angular Ng If,我在一个表中使用mat select(因此每行都有一个),当选择该行进行编辑时,该表将显示该行 mat select上有一个*ngIf,用于在不处于编辑模式时将其隐藏。它还由组件内的键/值映射填充。在Ngonit生命周期挂钩期间接收并设置这些值。mat select也不在表单中 当我选择编辑模式时,Mat Stat会出现,但它显示空白选项,迫使用户重新选择已经应用于该行的选项。我可以确认它们的键和值设置正确,typeId的对象值也设置正确 我已经尝试了在堆栈溢出上发现的几种方法,但到目前为止没有

我在一个表中使用mat select(因此每行都有一个),当选择该行进行编辑时,该表将显示该行

mat select上有一个*ngIf,用于在不处于编辑模式时将其隐藏。它还由组件内的键/值映射填充。在Ngonit生命周期挂钩期间接收并设置这些值。mat select也不在表单中

当我选择编辑模式时,Mat Stat会出现,但它显示空白选项,迫使用户重新选择已经应用于该行的选项。我可以确认它们的键和值设置正确,typeId的对象值也设置正确

我已经尝试了在堆栈溢出上发现的几种方法,但到目前为止没有一种有效。(例如,使用选定的属性,在mat select上使用[(值)],并尝试在出现时编写一个方法对其进行设置)

如何使用*ngIf显示mat select并在默认情况下显示当前值

HTML

<ng-container [matColumnDef]="myColumn">
    <th mat-header-cell *matHeaderCellDef mat-sort-header>Column 1</th>
    <td mat-cell *matCellDef="let object">
        <mat-form-field *ngIf="object.edit">
            <mat-select #objectTypeId="ngModel"
                        placeholder="Type"
                        disableOptionCentering
                        [(ngModel)]="object.objectTypeId"
                        [(value)]="object.objectTypeId"
                        required>
                <mat-option *ngFor="let objectType of objectTypeSelectViewModel?.map | keyvalue" value="{{objectType?.key}}">
                    {{objectType?.value}}
                </mat-option>
            </mat-select>
        </mat-form-field>
        <span *ngIf="!object.edit">{{object?.objectType}}</span>
    </td>
</ng-container>

第1栏
{{objectType?.value}
{{object?.objectType}