Created
June 2, 2021 18:37
-
-
Save shadow1349/b534c727e3f032e09d58cc63026ed3c7 to your computer and use it in GitHub Desktop.
Main Angular routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes: Routes = [ | |
/** | |
* When the path is '' it will know to redirect the user to the landing page. | |
* This is setting up the default route that the user will always land on at first. | |
*/ | |
{ path: '', redirectTo: '/landing', pathMatch: 'full' }, | |
{ | |
/** | |
* Landing will always be the first route we get to in order to bootstrap | |
* the virtual pages and make our lives a little easier in so far as routing | |
* goes. This will always go to the next main page afterwards. | |
*/ | |
path: 'landing', | |
loadChildren: () => | |
import('./routes/landing-route/landing-route.module').then( | |
(mod) => mod.LandingRouteModule | |
), | |
}, | |
{ | |
path: '404', | |
loadChildren: () => | |
import('./routes/not-found/not-found.module').then( | |
(mod) => mod.NotFoundModule | |
), | |
}, | |
{ | |
/** | |
* the ** path at the end of the array always hits any unknown routes for example | |
* if we try to go to /notaroute this this will be called and redirct the user to | |
* the 404 route. | |
* | |
* However, if you look at the main route main/:pageID that pageID could be ANY string | |
* so if we go to /main/notaroute the Angular router doesn't know that isn't a legit route | |
* so we have to know that ourselves from the response we get from the back-end and manually | |
* route to the 404 route. | |
*/ | |
path: '**', | |
redirectTo: '/404', | |
}, | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment