【发布时间】:2018-05-07 18:02:00
【问题描述】:
这是我的 html 文件中的内容:
<img src="{{( REST_URL + userId) || this.defaultImage }}" height="200" />
REST_URL 是用户/(在浏览器调用http://localhost:8080/user/123456 显示用户图像)
在我的component.ts文件中变量定义如下:
readonly REST_URL = 'user/';
userId: number;
并非所有用户都有图像,我希望在用户没有图像但它不起作用时显示默认图像......有什么想法吗?
【问题讨论】:
-
仅供参考,模板中的所有内容都被假定为
this的一部分,因此您无需在变量名前面加上它。
标签: html angular rest typescript spring-boot