【发布时间】:2021-05-18 21:55:04
【问题描述】:
我使用的是Angular材质表,mat-select和mat-option下拉,对于Media下拉,值为Email,lk_type为3287,我选择电话后,媒体值应该是phone,lk_type应该是3286 ,但是,当我单击编辑按钮时,this.currentData 没有更改下拉值,它仍然保持旧值,你知道我可以如何更改我的下拉值这个角垫选择和垫选项下拉?
add-person.component.html
<mat-table [dataSource]="dataSource">
<ng-container matColumnDef="person_contact_ID">
<mat-header-cell *matHeaderCellDef> Person Contact ID </mat-header-cell>
<mat-cell *matCellDef="let row">
<mat-form-field floatLabel="{{ row.editing ? 'float' : 'never'}}">
<input [(ngModel)]="row.currentData.person_contact_ID" placeholder="Person Contact ID" [disabled]="!row.editing" matInput>
</mat-form-field>
</mat-cell>
</ng-container>
<ng-container matColumnDef="media">
<mat-header-cell *matHeaderCellDef> Media </mat-header-cell>
<mat-cell *matCellDef="let row">
<mat-form-field>
<mat-select style="min-width: 200px;" placeholder="" value="{{row.currentData.lk_type}}">
<mat-option *ngFor="let media of mediaList " value="{{media.lookup_id}}">
{{ media.descr }}
</mat-option>
</mat-select>
</mat-form-field>
</mat-cell>
</ng-container>
<ng-container matColumnDef="actionsColumn">
<mat-cell *matCellDef="let row">
<button *ngIf="row.editing" mat-icon-button color="primary" focusable="false" (click)="row.confirmEditCreate_AddPerson()">
<i class="fa fa-check mat-icon"></i>
</button>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumn
s"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
tabledata.ts
confirmEditCreate_AddPerson(): boolean {
//_personService: TestRDB2Service;
if (this.id == -1)
return this.source.confirmCreate(this);
else
try {
this._http.put("https://localhost:5001/" + 'api/TestRDB2/AddUpdatePerson_Contact/', this.currentData).subscribe();
} catch (e) {
return e
}
return true;
//return this.source.confirmEdit(this);
}
【问题讨论】:
标签: angular dropdown mat-table