How to use ngStyle for background url in Angular 4

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

I have below html:

  
  • 7条回答
    •  暖寄归人
      2020-12-28 22:11

      The correct answer is [style.background-image]="'url(' + article.uri + ')'"

      but if you are using ngFor for carousel, make sure you have added class 'active' properly.

      This code will NOT working:

      
      

      You should use 'active' class for first item only!

      
      

      Hope it saves time for someone

    提交回复
    热议问题