【发布时间】:2019-01-20 07:31:15
【问题描述】:
我正在开发我的网站,我想从我的数据库中获取一张图片到我网站的标题中。
我有一个客户 ID,每个客户都有不同的徽标。现在我不知道如何用角度显示徽标。
这是我未完成的代码:
通过客户ID获取图片的组件:
logo: string;
companyName: string;
ngOnInit() {
this.currentLang = this.translate.getDefaultLang();
this.languages = this.translate.getLangs();
this.activatedRoute.queryParams.subscribe((params: Params) => {
const customerId = params["customerId"];
if (customerId) {
this.userService.getCustomer(customerId)
.subscribe(customer => {
this.logo = customer.logo, this.companyName = customer.name
});
}
});
}
我想在这里显示选定的徽标:
<div class="logo">
<span class="logo-type"><img src="{{ customer.logo }}"></span>
</div>
【问题讨论】:
-
您是否在控制台中遇到任何错误?
-
试试这个
-
正如 Chellappan 刚刚写的,你只有一个名为
logo的类变量,如果你想在 HTML 上下文中使用它,你应该为客户创建一个 var -
@Chellappan 不起作用
-
您是否遇到任何错误
标签: html angular image angular6