假设我有以下代码:
<img [src]="JwtService.characterImage(enemy)" class="{{enemy.status}}" (click)="sidenav.toggle();" style="cursor:pointer">
我如何从我的组件.ts文件中更改此img src asttribute?
在组件中添加imgSrc
原文链接:https://www.f2er.com/angularjs/143380.htmlclass Component { constructor(jwtService: JwtService) { this.imgSrc = JwtService.characterImage(enemy); } } <img [src]="imgSrc" class="{{enemy.status}}" (click)="sidenav.toggle();" style="cursor:pointer">