How to fix Angular Parser Error: Private identifiers are not supported. Unexpected private identifier: ...

Problem:

When trying to run our Angular application, you see the following error:

Error: src/app/my-component.html:18:31 - error NG5002: Parser Error: Private identifiers are not supported. Unexpected private identifier: #noName

related to source like

<span *ngIf="name ; else #noName">
    {{name}}
</span>
<ng-template #noName>
    <span><i>Name not configured</i></span>
</ng-template>

Solution

In the ; else #noName clause, remove the # character => ; else noName to fix the error:

<span *ngIf="name ; else noName">
    {{name}}
</span>
<ng-template #noName>
    <span><i>Name not configured</i></span>
</ng-template>