Упрощенно Я получил представление:
<table class="table table-bordered table-striped">
<tr>
<td>
<label>First Name</label>
<input type="text" class="form-control" [(ngModel)]="profile.FirstName">
</td>
<td>
<label>Last Name</label>
<input type="text" class="form-control" [(ngModel)]="profile.LastName">
</td>
</tr>
</table>
Компонент, в котором конструктор создает пустой профиль и ngOnInit проверяет наличие изменений:
profile: Profile;
sub: any;
constructor(private serv: ProfileService, private route: ActivatedRoute) {
this.profile = new Profile('', '');
}
ngOnInit(): void {
this.sub = this.route.params.subscribe(params => {
const id = params['id'];
this.serv.getProfile(id).subscribe(res => {
console.log(res);
this.profile = res;
// this.profile.LastName = res.LastName; doesn't work either
});
});
}
На консоли регистрируется правильный профиль , но поля таблицы не обновляются. Что не так? Спасибо за любую помощь!