My goal is to display a button when editing an input form. Initially, the button is hidden when the page loads but it should appear once any of the input fields are edited. I have also implemented highlighting for the input box that is being edited. However, whenever I try to edit my input field, I encounter an error message saying "NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'false'. Current value: 'true'". Despite this error, the button does not appear. Strangely, clicking on a random location in the browser makes the button visible. Can someone help me identify the issue here?
In my TypeScript file:
button: boolean;
ngOnInit(): void {
this.button = false;
}
highlight(input: string): string {
// logic for coloring...
if (input.dirty) {
// change color and show button
this.button= true;
}
return color;
}
In my HTML file:
<button *ngIf="button" label='Submit'>