Friday, 1 February 2019

Angular - Get current activated route and re-navigate to the same page with different route param

I am trying to get current route and navigate to the same route after changing the itemCode in the search textbox in the header. When I initially came to the page the parent route is "iauth/iauthedit/1706" then user navigates to the child route "/info", there are several other routes user can navigate from side Navigation bar which is not shown in the image below. When I change the item code to 1853 in the application header as shown in the image, the URL should change to "iauth/iauthedit/1853/info", how can I change the browser URL route param dynamically based on the current route URL on the browser ?, I am trying to find the current activated route which in current scenario parent "iauth/iauthedit/" from the browser URL, so that I can do the navigation

this.router.navigate(['iauth/iauthedit/', 1853];

image

Below is the current routes:

const itemAuthRoutes: Routes = [
    {
        path: 'iauthedit/:itemCode',
        children: [
            {
                path: '',
                canActivate: [AuthGuard],
                //data: { feature: AppFeature.AuthorizedItem },
                component: ItemAuthorizationEditComponent,
                children: [
                    {
                        path: 'info', component: ItemAuthorizationInfoEditComponent
                    }]
            }]
    }]



from Angular - Get current activated route and re-navigate to the same page with different route param

No comments:

Post a Comment