小编Дми*_*нко的帖子

角2。如何使用 *ngFor 在标签“href”中设置“URL”并在条件 *ngIf 中设置“{{theme.name}}”?

我需要切换模板。我有 12 个 css 文件需要动态加载

我有一个模板html。例如它的工作原理(硬编码):

<div class="container">
    <link rel='stylesheet'   href="/app/switchTemplate/css/amelia/bootstrap.min.css" *ngIf="currentTheme.name === 'amelia'" />
</div>
Run Code Online (Sandbox Code Playgroud)

当我使用 <*ngFor="let theme of themes"> 标记“href”时,它不起作用(动态)

<div class="container">
    <link rel='stylesheet'  *ngFor="let theme of themes"  href="{{theme.url}}" *ngIf="currentTheme.name === '{{theme.name}}'" />
</div>
Run Code Online (Sandbox Code Playgroud)

如何使用 *ngFor 在标签“href”中设置“URL”并在条件 *ngIf 中设置“{{theme.name}}”?

ngfor angular

3
推荐指数
1
解决办法
7848
查看次数

标签 统计

angular ×1

ngfor ×1