我有这个user.model.ts,我有一个用户列表,我可以通过单击过滤用户数据并将其置于引导模式中的按钮进行编辑,在选择标签中使用[ngModel]我可以获得国家我的用户,但是当我更改国家并提交表单时,我收到了当前国家,但没有收到它的 ID,应该注意的是,当我在选项中使用 [value] 时,它不会显示当前国家,我怎样才能得到值而不是名称?谢谢。
在 user.component.ts
updateUser(formActualizarTeam) {
console.log(this.user);
}
在 user.model.ts
export class UserModel{
name: string;
idCountry: number;
}
在 user.component.html
<form
#formUpdate="ngForm"
(ngSubmit)="updateUser(formUpdate)">
<select
id="country"
name="idCountry"
class="form-control"
[(ngModel)]="user.idCountry">
<option *ngFor="let c of countries">{{ c.name }}</option>
</select>
</form>
饮歌长啸
潇潇雨雨
守候你守候我
相关分类