【发布时间】:2017-12-19 14:30:34
【问题描述】:
我有一个具有这种样式的组件:[ngStyle]="{background: 'url(http://somedomain/api/'+event.EventID+'/otherUrlItems/image) no-repeat center center'}"
服务器上有组件,第一个组件作为背景图像添加。我应该如何为那些没有关联任何图像的组件添加默认背景图像?
更新: 这对我有用:
[ngStyle]="{'background': 'url(http://somedomain/api/'+event.EventID+'/otherUrlItems/image) no-repeat center center, url(https://placeimg.com/640/480/any) no-repeat center center'}"
【问题讨论】:
-
你的单引号放错了。
-
@Brian,这对我有帮助:stackblitz.com/edit/angular-4kwerh。感谢 Pierre Mallet。
标签: html css angular background