Pass parameters in Angular2 @RouteConfig redirectTo

Given a route config

@RouteConfig([
    new Route({ path: '/app/index.html', name: 'default', redirectTo: ['/View1] }),
    new Route({ path: '/view1/:param1/:param2/', name: 'View1', component: View1Component })
])

and param1, param2 being passed in as query parameters like so

http://legacy.com/app/index.html?param1=10&param2=15

how would I go about passing these parameters in the above redirectTo so that I’d end up with

http://legacy.com/app/#/view1/10/15

Is this possible to begin with?

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

This should work

@RouteConfig([
    new Route({ path: '/app', name: 'Default', redirectTo: ['/View1, {param1: 10, param2: 15}] }),
    new Route({ path: '/view1/:param1/:param2', name: 'View1', component: View1Component })
])

I modified the names an path a bit to make it compatible with the Angular2 style. If the /app/ really comes before index.html then there is something wrong in your configuration. See also Angular 2 router no base href set