Reputation: 6252
I have a couple of slides which have dynamic content that is added to them. The problem is the content inside of the slides doesn't scroll. So if I have a lot of items only some show and there is no ability to slide. How can I make it so the content in my lists slides inside of their slides?
<ion-content>
<ion-slides (change)="onSlideChanged($event)">
<ion-slide >
<ion-list>
<ion-item *ngFor="#item of items1; #i = index">
<h2>{{item}</h2>
</ion-item>
</ion-list>
</ion-slide>
<ion-slide>
<ion-list>
<ion-item *ngFor="#item of items2; #i = index">
<h2>{{item}</h2>
</ion-item>
</ion-list>
</ion-slide>
</ion-slides>
</ion-content>
Upvotes: 3
Views: 5516
Reputation: 1479
In controller, put:
ngAfterViewInit() {
this.slides.autoHeight = true;
}
Upvotes: 0
Reputation: 6347
Setting style='height:auto'
as stated in booyoungxu's answer disables sliding after you swipe on the first slide. style='overflow:scroll'
works best.
<ion-slides style="height: auto">
...
</ion-slides>
Upvotes: 0
Reputation: 143
I have the same problem,and I solve it like this:
<ion-slides style="height: auto">
<ion-slide *ngFor="#item of items">
<h1>{{item.title}}</h1>
<p>{{item.description}}</p>
</ion-slide>
</ion-slides>
Upvotes: 13
Reputation: 1135
Looks like you need to wrap your long content in a <scroll-content>
inside of each <ion-slide>
, for example:
<ion-slides>
<ion-slide *ngFor="#item of items">
<scroll-content>
<h1>{{item.title}}</h1>
<p>{{item.description}}</p>
</scroll-content>
</ion-slide>
</ion-slides>
Note, you may need to do a text-align:left
if you want the text to not be centered, since thats the default for content in <ion-slide>
.
Upvotes: 0