When running 'ng serve' or 'ng build' in Angular 10, I encountered a build error that stated:
ERROR in projects/project-navigator/src/app/modals/building-permissions.component.html:89:61 - error NG8002: Can't bind to 'ngClass' since it isn't a known property of 'button'.
...
The errors mentioned the following button:
<button type="button" (click)="doneButtonClicked()" [ngClass]="{ 'inactive-button': !permissionsHaveChanged || noOwner || (customMessageContainsHyperlinks && !allTogglesOff) }" twgTooltip [ttTextOnly]="doneDisabledTooltip" [ttDontShowIf]="permissionsHaveChanged && !noOwner && (!customMessageContainsHyperlinks || allTogglesOff)">
...
Upon investigation, several facts contradicted the errors:
- All variables referenced for the button were verified to exist in the component ts file.
- No html issues such as missing end tags or unterminated quotes were found.
- Similar elements in the template using ngClass, ttTextOnly, and ttDontShowIf functioned without errors.
- Moving the button to different parts of the template resulted in varying build outcomes, indicating position as the cause of errors.
- A simple change like replacing the button with a span still triggered errors.
- Adding an *ngIf="true" to the parent element of the button prevented build errors.
This behavior seemed inexplicable. The button's placement within the template appeared to directly influence the build errors. Any insights on what could be driving this unusual behavior?