Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic 3 - ion-slide inline css

I have Ionic3 App and ion-slides component on main page.

<ion-slides pager>
    <ion-slide *ngFor="let blog of blogs | async" >
      <h2>{{ blog.title }}</h2>
      <p>
      <a target="_blank" class="slider-read-more" ion-button outline color="secondary" (click)="blogDetail(blog)">ვრცლად</a>
      </p>
    </ion-slide>
  </ion-slides>

I want to add inline css background image using style

<ion-slide *ngFor="let blog of blogs | async" style="background:url(blog.image) no-repeat center center fixed;">

but can't pass blog.image inside. how to do this?

like image 254
Gocha Gochitashvili Avatar asked Sep 26 '17 10:09

Gocha Gochitashvili


2 Answers

You can try as shown below:

i.e. use backgroundImage as a property binding:

 <ion-slide [style.backgroundImage]="'url(' + blog.image + ')'"> ...
like image 120
Sampath Avatar answered Sep 22 '22 18:09

Sampath


I have used ngStyle directive to set an ion-slides style. v-3.0

[ngStyle]="{'background-image': 'url(' + blog.image + ')'}"
like image 45
Prashant Avatar answered Sep 21 '22 18:09

Prashant