[SOLVED] Async route: to get route.params

Hi, how could I get the route.params when I am using async route? Because I have a page with a list of links, the format of the links are just like: /about/usr1/, /about/usr2/ … etc. I define the routes /about/:usrId/, and I am going to call ajax to render the template page with response data. usrId will be the input parameter of my ajax call.

In normal case, i can get usrId by router.params.usrId, but it doesn’t work when I am using async route.

{
    path: '/about/:userId/',
    name:'about',
    async: function (routeTo, routeFrom, resolve, reject) {
        console.log('name1:'+mainView.router.currentRoute.url); // it shows "/"
        console.log('name1:'+app.views.current.router.currentRoute.path); // it shows "/"
        console.log('name1:'+app.views.current.router.currentRoute.params.userId); // it shows "undefined"

        app.request.post('getUsr.action?usrId=xxx', function (data) {
            resolve(
                {templateUrl: './about.html'},
                {
                    context:{
                        // response data
                    }
                }
            );
        });
    }
  },

Or is there a better to achieve?
Thanks for helping.

1 Like

It is in routeTo.params

1 Like

It works, thanks for your help.

1 Like