angular5 - 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>
解决方案
推荐阅读
- cocoa - 10.15 中的 PrefPane 不会重新打开外部窗口
- python-3.x - 使用 python 将 lat 和 long 上传到 umap/osm
- android - 如何从活动中获取 Surface View 属性?(表面视图和活动)
- delphi - Graphics32:从 GR32_PolygonsOld 转换
- python - 是否可以最大化python终端
- javascript - 如何在功能组件(世博相机)中使用 ref
- django - Gmail 安排在 Django 中发送电子邮件
- python - 为什么我的代码似乎跳过了所有一半的功能?
- javascript - 向我的索引路由获取 API 发出 POST 请求
- javascript - 如何在包含按钮的预先存在的表中添加一行