How to use ngStyle for background url in Angular 4

后端 未结 7 676
逝去的感伤
逝去的感伤 2020-12-28 21:56

I have below html:

  
  • 7条回答
    •  执笔经年
      2020-12-28 22:12

      you can use it by adding url path in a single variable. for example

      bgImageVariable="www.domain.com/path/img.jpg";
      
      [ngStyle]="{'background-image': 'url(' + bgImageVariable + ')'}"
      

    提交回复
    热议问题