I would like to swipe sideways between sections of a questionnaire. Each section has a header and a number of answered questions. I would like to add a vertical scroll on the questions, but can't figure out how to get it working. Here is my view:
<ion-view title="{{vm.title}}">
<ion-slide-box show-pager="true" class="has-header">
<ion-slide ng-repeat="s in vm.sections">
<ion-item class="item-royal">
{{s.Heading}}
</ion-item>
<ion-scroll>
<div class="card" ng-repeat="q in s.Questions">
<div class="item item-divider">
{{q.Text}}
</div>
<div class="item">
{{q.Answer}}
</div>
</div>
</ion-scroll>
</ion-slide>
</ion-slide-box>
</ion-view>
I found a solution that fixes the specific problem I was having, but creates another. I added a div to the ion-scroll and set heights on the ion-scroll and the new div:
<ion-scroll style="height:300px">
<div style="height:100%">
<div class="card" ng-repeat="q in s.Questions">
<div class="item item-divider">
{{q.Text}}
</div>
<div class="item">
{{q.Answer}}
</div>
</div>
</div>
</ion-scroll>
This causes two problems:
I don't want to specify the height of the ion-scroll in pixels - I'd like it to fill the remaining space in the window.
The pager appears in front of the scroll window - I'd like it to appear below.
EDIT Then I found a second solution:
<ion-view title="{{vm.title}}">
<ion-slide-box show-pager="true" class="has-header"
style="position:absolute; bottom: 0;left: 0;right: 0; ">
<ion-slide ng-repeat="s in vm.sections">
<ion-item class="item-royal">
{{s.Heading}}
</ion-item>
<ion-content>
<div class="card" ng-repeat="q in s.Questions">
<div class="item item-divider">
{{q.Text}}
</div>
<div class="item">
{{q.Answer}}
</div>
</div>
</ion-content>
</ion-slide>
</ion-slide-box>
</ion-view>
Changes made
Set the style of the ion-slide-box
to position:absolute; bottom: 0;left: 0;right: 0;
(The top is already specified by the has-header
class)
Use ion-content around the part I want to scroll instead of the ion-scroll
and the div
Live with the pager in front. It looks fine!