Wednesday, April 25, 2018

Have an optional parameter at the end of a route in Angular 4.

import { Routes, RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { MyComponent } from './whatever.component';
import { MyService } from './my-resolver.service';
export const MyRoutes: Routes = [
   {
      path: '',
      component: WhateverComponent,
      resolve: {
         'MyResolver': MyResolverService
      }
   },
   {
      path: ':id',
      component: WhateverComponent,
      resolve: {
         'MyResolver': MyResolverService
      }
   }
];
@NgModule({
   imports: [
      RouterModule.forChild(RelationshipsRoutes)
   ],
   exports: [RouterModule]
})
export class MyRoutesModule { }

No comments:

Post a Comment