Angular 2 - 我可以在标题部分的链接/样式表标记中使用 *ngIf 吗?
我想要这样的东西:
link rel='stylesheet' href="../assets/css/styles1.css" *ngIf="myvar === 'example'"
谢谢
最佳答案
在此处检查此解决方案:
https://github.com/angular/angular-cli/issues/4202#issuecomment-339420111
通过@TRAHOMOTO
<link rel="stylesheet" href="/theme/css/vendor-rtl.min.css" *ngIf="(locale$ | async)?.isRtl else ltrVendor">
<link rel="stylesheet" href="/theme/css/common-rtl.min.css" *ngIf="(locale$ | async)?.isRtl else ltrCommon">
<link rel="stylesheet" href="/theme/css/application-rtl.min.css" *ngIf="(locale$ | async)?.isRtl else ltrApplication">
<ng-template #ltrVendor>
<link rel="stylesheet" href="/theme/css/vendor.min.css">
</ng-template>
<ng-template #ltrCommon>
<link rel="stylesheet" href="/theme/css/common.min.css">
</ng-template>
<ng-template #ltrApplication>
<link rel="stylesheet" href="/theme/css/application.min.css">
</ng-template>
关于html - Angular 2 - 我可以在 <head> 部分的 <link rel ='stylesheet' 标签中使用 *ngIf 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48176303/