copy Copy chevron-down
Embryo-angular Routing/Navigation Embryo is compatible with parameter routing and lazy Loading. There are followings steps:
Go to src >> app >> and open app.routing.ts file and add routing like this:-
Copy { path: 'about/:keyword',component: AboutComponent }
{ path: 'cart', component: CartComponent } For Reference: https://angular.io/guide/routerarrow-up-right
1. Router navigate with params
If you want to use this routing in component. then go to src >> app >> and open component.ts file then do the followings:-
a) Add the the routing at top of the file like this:
Copy import { Router} from '@angular/router';
constructor(private router: Router){} b) Add in your desire component and add these line of code in your function:- For Example:-
Copy gotoAbout(){
this.router.navigate(['/about'], { queryParams: { keyword: 'Test' } });
} For Reference :- https://alligator.io/angular/query-parameters/arrow-up-right
2. RouterLink and RouterLinkActive
When the HTML element with RouterLink binding is clicked then the CSS classes bound with RouterLinkActive will be active. These directives are used are follows.
Copy <a routerLink="/cart" routerLinkActive="active-link">Cart</a>
<a [routerLink]="['/cart']">Cart</a> For Reference :- https://angular.io/guide/router#router-linksarrow-up-right
3. Lazy Loading
Lazy Loading in Embryo we need to create a routing module and a module for that component.
Go to src >> app >> and open app.routing.ts file and add routing like this:-
2. Inside the products module routing, Go to src >> app >> Products and open Products.routing.ts file and add routing like this:-
For Reference :- https://angular.io/guide/lazy-loading-ngmodulesarrow-up-right