This presentation talks about the Angular router covering the basic routing technique, Angular router events, guards, route resolvers, lazy loading of routes, and the latest changes in the Angular router (Angular v7, v8, v9)
@NgModule({ imports: [RouterModule.forRoot(routes)] }) Tip With a separate routing module, AppRoutingModule, export the RouterModule in the exports array.
}, { path: 'profile', component: ProfileComponent, }, { path: ‘**’, component: WildCardComponent } Tip Do not place the wildcard route before any other, as the route states are checked in the order defined in the configuration. configure the router states
<section class="body-section"> <router-outlet></router-outlet> </section> Tip Only see the route change but not view? place it exactly where you want the next component view.
route.params.id); } Create a guard ng g guard <guard-name> canActivate guard function always runs before fetching the data, pointless to load data before ensuring if activation will take place.
load a particular module only if it can be loaded. This means that check the criteria before loading it Read about preloading strategies here: https://angular.io/guide/ro uter#how-preloading- works