我有多个选择的对象,每个对象都有一个id,我想选择我以使模型保持我选择的那些对象的id,而不是整个对象的ID。
// model
public tiposContratosId?: any[],
// tipoContrato model
export class TipoContrato {
constructor(
public id?: number,
public tipo?: string,
public nombre?: string,
) {
}
}
// html
<select multiple class="form-control" id="field_tipoContrato" name="tipoContrato" [(ngModel)]="empleadoSpecification.tiposContratosId">
<option [ngValue]="itemOption.id" *ngFor="let itemOption of tiposContratos;">
{{itemOption.nombre}}</option>
</select>