[英]Surplus space between the variable and dot in Angular, how can I clean up it?
我的 Angular html 模板中有一个带有ng-container
的条件块。 渲染的 html 包含无法解释的空间,我该如何解决?
模板部分:
<span>
<ng-container [ngSwitch]="languageService.currentLang">
<ng-container
*ngSwitchCase="'en'">{{accessSubscriptionPlan.subjects[0]?.nameEn}}
</ng-container>
<ng-container
*ngSwitchCase="'ru'">{{accessSubscriptionPlan.subjects[0]?.nameRu}}
</ng-container>
<ng-container
*ngSwitchCase="'tt'">{{accessSubscriptionPlan.subjects[0]?.nameTt}}
</ng-container>
</ng-container>
<ng-container *ngIf="accessSubscriptionPlan.subjects[1]">
<!--<a [routerLink]="['/subject', accessSubscriptionPlan.subject?.id, 'view']">{{accessSubscriptionPlan.subject?.name}}</a>-->
<ng-container [ngSwitch]="languageService.currentLang">&
<ng-container
*ngSwitchCase="'en'">{{accessSubscriptionPlan.subjects[1]?.nameEn}}
</ng-container>
<ng-container
*ngSwitchCase="'ru'">{{accessSubscriptionPlan.subjects[1]?.nameRu}}
</ng-container>
<ng-container
*ngSwitchCase="'tt'">{{accessSubscriptionPlan.subjects[1]?.nameTt}}
</ng-container>
</ng-container>
</ng-container>
.</span>
<span
jhiTranslate="businesslogic.shop.subscription.platform">Platform Subscription</span>
最后生成的 html 是:
<div>
<span> <!----> <!----><!---->Mental arithmetics <!----> <!----> <!----><!----> <!---->& <!----><!---->Speed reading <!----> <!----> .</span>
<span jhitranslate="businesslogic.shop.subscription.platform">Platform Subscription.</span>
</div>
为什么我在...阅读和点之间有空格?
UPD。
我尝试不使用span
,但我仍然使用ng-container
并且仍然获得空格:
<div *ngIf="accessSubscriptionPlan.subjects[0]">
<!--<a [routerLink]="['/subject', accessSubscriptionPlan.subject?.id, 'view']">{{accessSubscriptionPlan.subject?.name}}</a>-->
<ng-container [ngSwitch]="languageService.currentLang">
<ng-container
*ngSwitchCase="'en'">{{accessSubscriptionPlan.subjects[0]?.nameEn}}
</ng-container>
<ng-container
*ngSwitchCase="'ru'">{{accessSubscriptionPlan.subjects[0]?.nameRu}}
</ng-container>
<ng-container
*ngSwitchCase="'tt'">{{accessSubscriptionPlan.subjects[0]?.nameTt}}
</ng-container>
</ng-container>
<ng-container *ngIf="accessSubscriptionPlan.subjects[1]">
<!--<a [routerLink]="['/subject', accessSubscriptionPlan.subject?.id, 'view']">{{accessSubscriptionPlan.subject?.name}}</a>-->
<ng-container [ngSwitch]="languageService.currentLang">&
<ng-container
*ngSwitchCase="'en'">{{accessSubscriptionPlan.subjects[1]?.nameEn}}
</ng-container>
<ng-container
*ngSwitchCase="'ru'">{{accessSubscriptionPlan.subjects[1]?.nameRu}}
</ng-container>
<ng-container
*ngSwitchCase="'tt'">{{accessSubscriptionPlan.subjects[1]?.nameTt}}
</ng-container>
</ng-container>
</ng-container>
.
<span
jhiTranslate="businesslogic.shop.subscription.platform">Platform Subscription</span>
</div>
output 是:
<div> <!----> <!----><!---->Mental arithmetics <!----> <!----> <!----> . <span jhitranslate="businesslogic.shop.subscription.platform">Platform Subscription.</span> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.