Один из способов сделать это - использовать фиксированный div
с некоторыми стилями, чтобы он выглядел как слайд. Результат будет примерно таким:
Пожалуйста, ознакомьтесь с этой демонстрацией стекаблиц .
Компонент
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html',
styleUrls: ['home.scss']
})
export class HomePage {
arrayOfOffers: any[] = [];
constructor(public navCtrl: NavController) {
this.arrayOfOffers = [
{ id: 1, name: 'Ali', color: 'red'},
{ id: 2, name: 'Sara', color: 'green'},
{ id: 3, name: 'Joanna', color: 'purple'}
]
}
}
View
<ion-header>
<ion-navbar>
<ion-title>Home</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<div class="compare-section">
<!-- Fixed section -->
<div class="compare-section__fixed">
<p>Fixed Slide</p>
</div>
<!-- Slides -->
<ion-slides class="compare-section__slides" slidesPerView="2">
<ion-slide *ngFor="let offer of arrayOfOffers; let i = index"
[style.background-color]="offer.color">
{{ offer.name }}
</ion-slide>
</ion-slides>
</div>
</ion-content>
Стили
.compare-section {
height: 100%;
width: 100%;
overflow: hidden;
display: flex;
justify-content: flex-start;
align-items: flex-start;
}
.compare-section__fixed {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
min-width: 120px; // Change this based on your requirements
background: blue;
}