如何修复 Angular Parser Error: Private identifiers are not supported. Unexpected private identifier: ...
问题:
尝试运行 Angular 应用时,你看到以下错误:
error_message.txt
Error: src/app/my-component.html:18:31 - error NG5002: Parser Error: Private identifiers are not supported. Unexpected private identifier: #noName与如下源代码相关
ngif_private_identifier_bad.html
<span *ngIf="name ; else #noName">
{{name}}
</span>
<ng-template #noName>
<span><i>Name not configured</i></span>
</ng-template>解决方案
在 ; else #noName 子句中,删除 # 字符 => ; else noName 来修复错误:
ngif_private_identifier_fixed.html
<span *ngIf="name ; else noName">
{{name}}
</span>
<ng-template #noName>
<span><i>Name not configured</i></span>
</ng-template>Check out similar posts by category:
Angular, Typescript
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow