angular link component code example
Example 1: call a function whenever routerlink is clicke angular
<a class="nav-link" [routerLink]="['/home']" (click)="doSomeLogic()">Home</a>
Example 2: angular navigate using component
import {Router} from '@angular/router'; // import router from angular router
export class Component{ // Example component..
constructor(private route:Router){}
go(){
this.route.navigate(['/page']); // navigate to other page
}
}
Example 3: home page routing in angular
const routes: Routes = [
{ path: 'home_page_path', component: HomePageComponent }
];
add this in app routing file
/*
I Hope it will Help You.
Namaste _/\_
*/
Example 4: router params angular
// Navigate and send Params
this.router.navigate(['/users/edit/', user.id]);