0

I try to set an image i get from my api as background image from my header. But it will not work as expected...

This is my code:

    <div class="container">
        <div class="header" [ngStyle]="{background: 'url('userProfile.headerImagePath')'}">
        ...

css

.header {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 500px;
    min-width: 100%;
    background-color: yellowgreen;
}
Léon Zimmermann
  • 123
  • 1
  • 14
  • check this answer. this might helpful https://stackoverflow.com/questions/34875426/how-to-add-background-image-using-ngstyle-angular2 – prabath Oct 18 '20 at 14:29

1 Answers1

0

Please use the below code.

        <div class="header" [ngStyle]="{background: 'url('+userProfile.headerImagePath+')'}">
        ...
abhishek sahu
  • 648
  • 4
  • 8