I\'m trying to access a native element in order to focus on it when another element is clicked (much like the html attribute \"for\" - for cannot be used on elements of th
You'll also get this error if your target element is inside a hidden element. If this is your HTML:
Hello World
Your @ViewChild('sp') sp will be undefined.
@ViewChild('sp') sp
In such a case, then don't use *ngIf.
*ngIf
Instead use a class to show/hide your element being hidden.
...