Jak opravit Angular Parser Error: Private identifiers are not supported. Unexpected private identifier: ...

Problém:

Při pokusu o spuštění vaší Angular aplikace vidíte následující chybu:

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

vztahující se ke zdroji jako

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

Řešení

V ; else #noName klauzuli odstraňte znak # => ; else noName pro opravu chyby:

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

Podívejte se na podobné články podle kategorie: Angular Typescript