I'm trying to set view field values when "user_details" object is populated in the .ts on the ngOnInit() execution.
This is the .ts where I'm filling the user_details object.
export class ProfileComponent implements OnInit {
user_details = {
name: '',
first_surname: '',
second_surname: '',
age: '',
birdth_date: '',
location: '',
phone: '',
image: ''
};
constructor(private authService: AuthService, private router: Router) { }
ngOnInit(): void {
this.authService.getProfile()
.subscribe(
res => {
this.user_details = res;
console.log(this.user_details)
},
err => console.log(err)
);
}
As you see, the object is getting correct data.
This is the form where I need to fill the fields.
<div class="container p-4">
<form (submit)="updateProfile()">
<div class="row d-flex justify-content-center text-white">
<div class="col-md-6">
<div class="form-group">
<label for="name">Name</label>
<input type="text" [(ngModel)]="user_details.name" value={{user_details.name}} name="name" class="form-control" id="name" placeholder="Name">
</div>
<div class="form-group">
<label for="first_surname">First surname</label>
<input type="text" [(ngModel)]="user_details.first_surname" name="first_surname" value={{user_details.first_surname}} class="form-control" id="first_surname" placeholder="First surname">
</div>
...
How can I set the values of the view fields with this object data? I need to be displayed "user_details" fields in the view, and my view is empty.