Skip to content

Instantly share code, notes, and snippets.

@hoangtranson
Last active July 1, 2019 09:32
Show Gist options
  • Save hoangtranson/e93bc0c3eebd8e4d24ff3c2e01e6d501 to your computer and use it in GitHub Desktop.
Save hoangtranson/e93bc0c3eebd8e4d24ff3c2e01e6d501 to your computer and use it in GitHub Desktop.
Accessing URL parameter in Angular
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { DashboardComponent } from './dashboard/dashboard.component';
import { HeroesComponent } from './heroes/heroes.component';
import { HeroDetailComponent } from './hero-detail/hero-detail.component';
const routes: Routes = [
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
{ path: 'dashboard', component: DashboardComponent },
{ path: 'detail/:id', component: HeroDetailComponent },
{ path: 'heroes', component: HeroesComponent }
];
@NgModule({
imports: [ RouterModule.forRoot(routes) ],
exports: [ RouterModule ]
})
export class AppRoutingModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment