javascript - how do i set a style attribute value from an object data? -


i thought pretty easy, don't have clue of how make work, last try on style attribute in button tag, i've searched web , hour , nothing works.

<ion-header>    <ion-navbar color="danger">     <ion-title>cadenas</ion-title>   </ion-navbar>  </ion-header>   <ion-content  container class="card-cadenasmercados">    <button id="sucursal"           *ngfor="let cadena of cadenascollection"           [navpush]="sucursalespage"           [navparams]="cadena"           style:background='{{cadena.img}}'>     {{cadena.nombre}}</button>  </ion-content> 

you can use ngstyle: https://angular.io/api/common/ngstyle

<button id="sucursal"           *ngfor="let cadena of cadenascollection"           [navpush]="sucursalespage"           [navparams]="cadena"           [ngstyle]="{'background': cadena.img}">     {{cadena.nombre}}</button> 

this assumes cadena.img "url(someimage.png)"


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -