angularngx-admin

angular style.background-image binding


in ngx-admin, there is

style.background-image 

attribute,

which library parses this style.background-image ?

  <div class="cover" style.background-image="url('{{track.cover}}')"></div>

https://github.com/akveo/ngx-admin/blob/5e44070239e3b133aeb97b57bd59d04867ee1eb3/src/app/pages/dashboard/rooms/player/player.component.html#L6


Solution

  • This method of applying style is know as applying the style using attribute binding and Angular itself parses this. In Angular we normally bind the component properties in our template, but we can bind attributes too in our template.

    Here background-image is an attribute of style which is getting bound to cover property of the track object.