How can i insert page in ionic 3 segment layout

2019-08-07 02:19发布

问题:

This is my app with Tabs layout

Once i click on profile tab i push a page say Profile.ts which contains ion-segment in its own template Profile.html

Profile.html

<ion-content>
  <ion-segment [(ngModel)]="whichPage" color="primary">
  <ion-segment-button style="font-size: 11px" value="Personal">
    Personal
  </ion-segment-button>
</ion-segment>

<div [ngSwitch]="whichPage">
 <ion-list *ngSwitchCase="'Personal'">
 <ion-item>
   **HERE HOW CAN I DISPLAY ANOTHER PAGE WHICH I HAVE CREATED USING IONIC 
   GENERATE PAGE Personal**
 </ion-item>
</div>
</ion-content>

回答1:

You wont be able to display an entire page but you can set a component. This is because a particular page can only have one ion-content tag.

You will have to remove the header, footer and content parent tags from profile. You can have the profile content within Profile.html. and then use it within your segment as a Child component as:

<ion-list *ngSwitchCase="'Personal'">
 <ion-item>
   <PersonalComponent></PersonalComponent>
 </ion-item>
</ion-list>