angulartypescriptrouteroutlet

How to get outlet params from ActivatedRoute (Angular2)


My routes are defined as:

    path: 'geooperations',
    component: GeoMetricsComponent,
    children: [
      { path: ':idgeooperationmetrictype', component: DetailGeoMetricTypeComponent, outlet: 'geo' },
      { path: ':idgeooperationmetrictype/edit', component: DetailGeoMetricTypeComponent, outlet: 'geo' },
      { path: '/new', component: DetailGeoMetricTypeComponent, outlet: 'geo' }
    ]

Example: URL: geooperations/(geo:c56da64c-0ef5-4894-83ee-043818b44e14)

outlet : 'geo'
idgeooperationmetrictype: 'c56da64c-0ef5-4894-83ee-043818b44e14'

How do I can get the 'idgeooperationmetrictype' from the ActivatedRoute ?


Solution

  • Solved the issue by using the snapshot.params :

    this.activatedRoute.snapshot.params.subscribe(params => {           
       console.log(params['idgeooperationmetrictype']);
    });