1

I am setting background image with ngStyle, like this:

<section [ngStyle]="{'background': 'url(' + backgroundUrl + ') no-repeat 0 0 / cover'}" class="slider flex-center">

In .ts file:

this.backgroundUrl = this.homeModelResponse.featuredStories[0].fullHDUrl;

The problem is, if user uploads the same images, i get url like this:

https://..something/264/2970/7745/9960/rawpixel-com-256641_(1)_org_hd_ready.jpg.jpg

with (1) in brackets, and my guess is that css doesn't work good with that, all other images are displayed but just the copies with this type of path are not.

It works with img tag but doesn't with background property in css.

Anyone knows whats wrong?

2 Answers 2

1

Found the solution.

Background image does not allow (), space, single quotes and double quotes in the image path.

Sign up to request clarification or add additional context in comments.

Comments

0

You can add height and width of section tag.

I have create a demo on Stackblitz

<section style="height:300px;width:300px;" [ngStyle]="{'background': 'url(' + backgroundUrl + ') no-repeat 0 0 / cover'}" class="slider flex-center">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.