Reputation: 71
I've got the following problem: I want to insert a background image to my website with ngStyle. The following code works fine:
<div [ngStyle]="{'background-image': 'url(' + myBackgroundUrl + ')', 'width': '224px', 'height': '248px'}"></div>
However, if I want to add some more "attributes" to the background-image, the image isn't visible anymore:
<div [ngStyle]="{'background-image': 'url(' + myBackgroundUrl + ') no-repeat -228px 0', 'width': '224px', 'height': '248px'}"></div>
Upvotes: 2
Views: 491
Reputation: 214017
The background-image property sets one or more background images for an element.
If you want to add some more "attributes" then use background instead:
<div [ngStyle]="{
'background': 'url(' + myBackgroundUrl + ') no-repeat -228px 0',
'width': '224px',
'height': '248px'
}"></div>
Upvotes: 3