首页 > 解决方案 > angular 5 将 *ngFor 中的值转换为字符串

问题描述

我有以下 div 块,我正在迭代 observable Next 当我尝试设置 ngStyle 时,我将 ngStyle 的值作为 [Object object] 而不是 string 。

 <div class = "circle-logo-btm pull-left cp" *ngFor= "let imageUrl of (allAppBGIMageURLs$ | async)" (click)="selectApplication(1)">
              <div [ngStyle]="{'background-image':'url(' + imageUrl + ')'}" class=" btn-round"></div>
          </div>

这是渲染的结果,它作为一个对象而不是实际的图像 url

 <div xmlns="http://www.w3.org/1999/xhtml" _ngcontent-c3="" class=" btn-round" ng-reflect-ng-style="[object Object]"></div>

标签: angular5

解决方案


推荐阅读