如何使用angular中的select将id从一个服务保存到另一个服务



我想使用select这是我的方法将从一个服务获得的id保存到另一个服务中

<select class="form-control" id="select_fac" [(ngModel)]="rep.idfac">
<option selected disabled>Select the company</option>
<option *ngFor="let fact of factory" [ngValue]="fact.id_fac">{{fact.name}}</option>
</select>

我的组件中有这个.ts

factory: Factory[]=[];
rep:Representative= new Representative();

尝试使用ReactiveForms:Angular Docs:Reactive Forms

您可以使用formContralName 绑定数据

相关内容

最新更新