代码之家  ›  专栏  ›  技术社区  ›  j10

使用angular6从mongodb获取图像到网站

  •  1
  • j10  · 技术社区  · 6 年前

    我有一个客户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>
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   j10    6 年前

    明白了,很简单。就写吧 'logo' :

    <div class="logo">
       <span class="logo-type"><img src="{{ 'logo' }}"></span>
    </div>
    
    推荐文章