Powered by AI
**1. Lazy Loading**
Lazy loading allows you to load feature modules only when needed, improving
the initial load time of the application. This is configured using the
loadChildren property in the route configuration.
**8. URL Serialization**
The router serializes the URL into a string that can be used in the browser's
address bar. This includes encoding special characters and handling query
parameters and fragments.
**9. Router Events**
The router emits various events during the navigation lifecycle, such as
NavigationStart, NavigationEnd, NavigationError, etc. These can be used to
track and respond to navigation changes.
**10. Example of Navigation with Parameters**
Here's an example of navigating to a route with parameters:
import { Component } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-navigation',
template: `<button (click)="goToDetails(1)">Go to
Details</button>`
})
export class NavigationComponent {
constructor(private router: Router) {}
goToDetails(id: number) {
this.router.navigate(['/details', id], { queryParams: { ref:
'home' } });
}
}
This example navigates to the /details/1 route with a query parameter
ref=home.