I just started learning Angular and I'm currently working on a small project. After following tutorials on two-way bindings, I attempted to implement it in my project. However, when I try to set values in the HTML for my component, it doesn't seem to work. It's probably a simple mistake due to my lack of experience with Angular.
One-way binding (using []) works fine, but when I add () to the HTML tags, it stops working.
Here is an excerpt from the HTML code of my custom component:
<form class="form_MyProfile">
<table class="myprofile_width" cellspacing="0">
...
</table>
</form>
And here is part of the TypeScript code from the same component:
@Component({
selector: 'app-my-profile',
templateUrl: './my-profile.component.html',
styleUrls: ['./my-profile.component.css']
} )
...
loadProfile(): void {
this.repo.getData('api/Profile')
.subscribe((res: UserRegister) => {
this.userProfile = res;
//assigning values to variables here
},
error => {
this.alertService.error(error);
});
}
The method loadProfile makes an API call that retrieves the data successfully, but setting the values doesn't seem to work as expected.
If anyone can identify the issue, I would greatly appreciate your help.
Have a wonderful day,
Lio