Angular 4+提供了一种在模板文件中执行if / else逻辑的方法,例如
<ng-container *ngIf="isSaveSuccess; else elseBlock">
Save succeeded.
</ng-container>
<ng-template #elseBlock>
Save failed.
</ng-template>
但是,这需要您指定唯一的ng-template ID。我们担心使用这种方法意外地引入重复的“elseBlock”模板,例如
<ng-container *ngIf="isSaveSuccess; else elseBlock">
Save succeeded.
</ng-container>
<ng-template #elseBlock>
Save failed.
</ng-template>
...
<ng-container *ngIf="isUpdateSuccess; else elseBlock">
Update succeeded.
</ng-container>
<ng-template #elseBlock> <!-- duplicate id -->
Update failed.
</ng-template>
有没有办法将Angular模板文件lint以检测重复的ng-template id?