Answers for "angular a link routing"

7

redirect angular

import { RoleComponent } from './role/role.component';
import { AppComponent } from './app.component';
import { NgModule }             from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const routes: Routes = [
  { path: '', redirectTo: '/AppComponent', pathMatch: 'full' },
  { path: 'role', component: RoleComponent },

];

@NgModule({
  imports: [ RouterModule.forRoot(routes) ],
  exports: [ RouterModule ]
})
export class AppRoutingModule {
  constructor(private router: Router)
}

functionOnWhichRedirectShouldHappen(){
  router.navigate(['/role']);
}
Posted by: Guest on February-27-2020
3

call a function whenever routerlink is clicke angular

<a class="nav-link" [routerLink]="['/home']" (click)="doSomeLogic()">Home</a>
Posted by: Guest on July-09-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language