I am facing an issue with triggering a function in the component:
componentA.ts
html = 'hey';
this.onElementSelected(r => this.change());
public change() {
console.log(this.html);
if (this.html === 'hey') {
this.html = 'oh, hello!';
console.log(this.html);
} else {
this.html = 'hey';
}
}
componentA.html
This is the code of the associated template:
<div *ngIf="html">{{html}}</div>
While I can see the html variable change with console.log(), it doesn't reflect the change in the template. How can I update the template without using a button within the template?
I have already tested and confirmed that using a button works, but I need the event of change to be triggered by the component itself.
Any suggestions would be greatly appreciated. Thank you for your help.