Fireship · @fireship

Ionic 4 - Routing and Navigation Guide

Uploaded September 4, 2018 · Length 11:38

Ionic 4 - Routing and Navigation Guide

Summary

Ionic 4 routing and navigation guide using the angular router, including lazy loading and dynamic data routing.

  • ionic 4 routing
  • angular router
  • lazy loading
  • ionic navigation
  • dynamic routing

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    [Music]

  2. 0:06

    the single most important change in

  3. 0:08

    ionic four is the way navigation works

  4. 0:10

    if you're migrating from version three

  5. 0:12

    then you're probably familiar with ionic

  6. 0:13

    snap controller and the ion nap

  7. 0:15

    component but they've been deprecated in

  8. 0:17

    favor of the angular router which is far

  9. 0:19

    more powerful in today's video you'll

  10. 0:21

    learn everything you need to know to be

  11. 0:23

    successful with the angular router in

  12. 0:25

    ionic 4 and I'll show you a few advanced

  13. 0:27

    techniques that you can start putting to

  14. 0:28

    use right away if you're new here like

  15. 0:30

    and subscribe and you can find the

  16. 0:32

    source code at angular firebase com so

  17. 0:35

    prior to ionic 4 the framework used its

  18. 0:37

    own built in nav controller and

  19. 0:39

    component to handle the navigation

  20. 0:40

    between pages in a push pop style way

  21. 0:43

    that you would see on a mobile

  22. 0:44

    application I'd like to point out that

  23. 0:46

    the nav controller will still

  24. 0:47

    technically work in ionic 4 so you might

  25. 0:49

    see some tutorials out there on the web

  26. 0:50

    that use it but it's not the preferred

  27. 0:52

    way to handle navigation and will likely

  28. 0:54

    not be possible in the future I'm going

  29. 0:56

    to go ahead and assume that you know

  30. 0:57

    nothing about the angular router so

  31. 0:59

    we'll start with the absolute basics and

  32. 1:01

    then build up to some pretty advanced

  33. 1:02

    concepts towards the end and also make

  34. 1:05

    sure to watch my angular routing basics

  35. 1:07

    video which is very relevant to the

  36. 1:08

    topic at hand here

  37. 1:09

    and before we do anything I want to give

  38. 1:11

    you a pro tip and that is to install the

  39. 1:14

    augury plugin for angular you can find

  40. 1:16

    it on the chrome store and it will help

  41. 1:18

    you a ton by visualizing your actual

  42. 1:20

    router tree so you can see here that

  43. 1:22

    everything kind of starts from the app

  44. 1:23

    component then we have a couple of lazy

  45. 1:25

    loaded pages and so on

  46. 1:27

    this is a pretty basic set up here but

  47. 1:29

    it becomes very valuable as your

  48. 1:31

    complexity grows I've gone ahead and

  49. 1:34

    generated a brand new ionic 4 app that's

  50. 1:36

    using the tabs template and when we open

  51. 1:39

    this application up the first place

  52. 1:40

    we'll go is into the app directory and

  53. 1:43

    then open the app routing module the

  54. 1:46

    only thing you'll ever really change in

  55. 1:47

    this file is the routes array which is

  56. 1:49

    an array of objects where you define the

  57. 1:51

    actual routes in your application there

  58. 1:53

    are three basic types of routes that you

  59. 1:55

    can define your typical vanilla route

  60. 1:57

    would just be one that loads a component

  61. 1:59

    then an ionic we have lazy loaded routes