Skip to content
Advertisement

Angular 12 – *ngIf;Then;Else – must be a TemplateRef, but received ‘[object HTMLInputElement]’

After migrating Angular 6.x to Angular 12.x, I’m facing template related issues.

UPDATED

I’ve my code like this

JavaScript

Below error i got

ERROR Error: ngIfElse must be a TemplateRef, but received ‘[object HTMLInputElement]’

What i tried?

JavaScript

ts

JavaScript

Could someone help me how to can refactor pieces ?

Thanks for the help guys

Advertisement

Answer

so the problem is very simple, you have #selectAll twice in your HTML code. to fix this you need to rename one of them

JavaScript

and if you use the selectAll input only in your function, you don’t need the @ViewChild but you can do it like this: (just an improvement, not mandatory)

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement