我这样做的方式是向子路由器定义添加附加信息,例如:
configureRouter(config, router){
config.map([
{ route: [''], name: 'empty', moduleId: './empty', nav: false, msg:"choose application from the left" },
{ route: 'ApplicationDetail/:id', name: 'applicationDetail', moduleId: './applicationDetail', nav: false, getPickLists : () => { return this.getPickLists()}, notifyHandler : ()=>{return this.updateHandler()} }
]);
在本示例的第一条路由中,我通过将我自己的属性“msg”添加到路由对象来传递一条文本消息。在第二条路线中,我传入了一些事件处理程序,但可能是一些自定义对象或其他任何东西。
在子模型中,我在 activate() 方法中收到这些附加元素:
export class empty{
message;
activate(params, routeconfig){
this.message=routeconfig.msg || "";
}
}
我想在您的情况下,您会将用户对象添加到子路由器定义中。