项目作者: mallajay

项目描述 :
Ionic 4 side menu with tabs using ionic page and ionic components
高级语言: TypeScript
项目地址: git://github.com/mallajay/Ionic-4-Tab-With-Side-Menu.git
创建时间: 2020-01-12T06:56:26Z
项目社区:https://github.com/mallajay/Ionic-4-Tab-With-Side-Menu

开源协议:

下载


Ionic-4 Tab-With-Side-Menu With Angular Component and Ionic Page

  • Add New project
    • by using ionic start new-app
      • From Startting Template select sidemenu
        1. Starter template: (Use arrow keys)
        2. - tabs | A starting project with a simple tabbed interface
        3. - sidemenu | A starting project with a side menu with navigation in the content area
        4. - blank | A blank starter project
        5. - my-first-app | An example application that builds a camera with gallery
        6. - conference | A kitchen-sink application that shows off all Ionic has to offer
        • Delete Home File and List File
        • Regenerate home and list file by running command ionic g page home & ionic g page list
        • Generate page for tab by running command ionic g page home/schedule && ionic g page home/speaker
        • Generate page for tab by running command ionic g c list/map && ionic g c list/music && ionic g c list/movies

By using page Routing

home.page.html

  1. <ion-header>
  2. <ion-toolbar>
  3. <ion-buttons slot="start">
  4. <ion-menu-button></ion-menu-button>
  5. </ion-buttons>
  6. <ion-title>Home</ion-title>
  7. </ion-toolbar>
  8. </ion-header>
  9. <ion-content>
  10. <ion-tabs>
  11. <ion-tab-bar slot="bottom">
  12. <ion-tab-button tab="schedule">
  13. <ion-icon name="calendar"></ion-icon>
  14. <ion-label>Schedule</ion-label>
  15. <ion-badge>6</ion-badge>
  16. </ion-tab-button>
  17. <ion-tab-button tab="speaker">
  18. <ion-icon name="contacts"></ion-icon>
  19. <ion-label>Speakers</ion-label>
  20. </ion-tab-button>
  21. </ion-tab-bar>
  22. </ion-tabs>
  23. </ion-content>

home-routing.module

  1. import { NgModule } from "@angular/core";
  2. import { Routes, RouterModule } from "@angular/router";
  3. import { HomePage } from "./home.page";
  4. const routes: Routes = [
  5. {
  6. path: "",
  7. component: HomePage,
  8. children: [
  9. {
  10. path: "",
  11. children: [
  12. {
  13. path: "schedule",
  14. loadChildren: () =>
  15. import("./schedule/schedule.module").then(
  16. m => m.SchedulePageModule
  17. )
  18. },
  19. {
  20. path: "speaker",
  21. loadChildren: () =>
  22. import("./speaker/speaker.module").then(m => m.SpeakerPageModule)
  23. },
  24. {
  25. path: "",
  26. redirectTo: "/home/schedule",
  27. pathMatch: "full"
  28. }
  29. ]
  30. }
  31. ]
  32. },
  33. {
  34. path: "",
  35. redirectTo: "/home/schedule",
  36. pathMatch: "full"
  37. }
  38. ];
  39. @NgModule({
  40. imports: [RouterModule.forChild(routes)],
  41. exports: [RouterModule]
  42. })
  43. export class HomePageRoutingModule {}

By using Components

list-routing.module

  1. import { MoviesComponent } from "./movies/movies.component";
  2. import { MusicComponent } from "./music/music.component";
  3. import { MapComponent } from "./map/map.component";
  4. import { NgModule } from "@angular/core";
  5. import { Routes, RouterModule } from "@angular/router";
  6. import { ListPage } from "./list.page";
  7. const routes: Routes = [
  8. {
  9. path: "",
  10. component: ListPage,
  11. children: [
  12. {
  13. path: "",
  14. children: [
  15. {
  16. path: "map",
  17. component: MapComponent
  18. },
  19. {
  20. path: "music",
  21. component: MusicComponent
  22. },
  23. {
  24. path: "movies",
  25. component: MoviesComponent
  26. },
  27. {
  28. path: "",
  29. redirectTo: "/list/map",
  30. pathMatch: "full"
  31. }
  32. ]
  33. }
  34. ]
  35. },
  36. {
  37. path: "",
  38. redirectTo: "/list/map",
  39. pathMatch: "full"
  40. }
  41. ];
  42. @NgModule({
  43. imports: [RouterModule.forChild(routes)],
  44. exports: [RouterModule]
  45. })
  46. export class ListPageRoutingModule {}

list.page.html

  1. <ion-header>
  2. <ion-toolbar>
  3. <ion-buttons slot="start">
  4. <ion-menu-button></ion-menu-button>
  5. </ion-buttons>
  6. <ion-title>list</ion-title>
  7. </ion-toolbar>
  8. </ion-header>
  9. <ion-tab-bar slot="bottom">
  10. <ion-tab-button tab="map">
  11. <ion-icon name="map"></ion-icon>
  12. <ion-label>Map</ion-label>
  13. </ion-tab-button>
  14. <ion-tab-button tab="music">
  15. <ion-label>Music</ion-label>
  16. <ion-icon name="musical-note"></ion-icon>
  17. </ion-tab-button>
  18. <ion-tab-button tab="movies">
  19. <ion-label>Movies</ion-label>
  20. <ion-icon name="videocam"></ion-icon>
  21. </ion-tab-button>
  22. </ion-tab-bar>
  23. </ion-tabs>