我有以下代码:Angular2动态IMG SRC
<a routerLink="/dashboard" routerLinkActive="active" #rla="routerLinkActive">
<img src="/assets/navigation/dashboard-icon-active.svg" />
<template [ngIf]="!isSmallSidebar">
Dashboard
</template>
</a>
运行我的应用我看到的图像正确显示。不过,如果当前路线处于活动状态,我希望图像更改。所以我做:
<a routerLink="/dashboard" routerLinkActive="active" #rla="routerLinkActive">
<!-- <img
id="re-nav-dashboard-img"
src={{ rla.isActive ? './assets/navigation/dashboard-icon-active.svg' : './assets/navigation/dashboard-icon.svg' }} /> -->
<template [ngIf]="!isSmallSidebar">
Dashboard
</template>
</a>
什么我做错了或这是一个错误?
如果绑定的值是一个字符串,它们是等价的。 –
我的方法有什么不同? – mp3por
@GünterZöchbauer我不知道,但在阅读https://angular.io/docs/ts/latest/guide/template-syntax.html#interpolation后,我必须同意:) –