在Angular 5中同时保存'id'和'name'

时间:2018-08-07 08:24:33

标签: angular angular-material angular5 angular2-template angular2-forms

使用Angular 5,Material组件和Firebase处理项目。是否可以通过一个字段存储两个值。 下面是我的代码,我从客户端表获取数据并在下拉列表中显示名称,但存储“ client_id”。我想将client_name也与client_id一起存储。

<mat-form-field>
            <mat-select placeholder=" Select Client" formControlName="client_id" required>
               <mat-option *ngFor="let cli of clientsarray; let i = index " [value]="cli.prodid">{{cli.fname}} {{cli.lname}}</mat-option>
            </mat-select>
 </mat-form-field>

1 个答案:

答案 0 :(得分:1)

绑定到对象{在这种情况下为cli

<mat-option *ngFor="let cli of clientsarray; let i = index " [value]="cli">{{cli.fname}} {{cli.lname}}</mat-option>