任何人都可以通过解决路由器问题来帮助我。
我有一个主要模块“app.module”,它包含很少的子模块。 App.module有app.routers文件,用于描述其子模块的延迟加载。
app.routers文件如下所示:
..
{
path: "sign-up", // to sing up new users
loadChildren: "app/signup/sign-up.module"
},
{
path: "home", // to see home page
loadChildren: "app/home/home.module"
},
..
etc
..
我想使用解析路由器从服务器加载一些数据,我想在app.component加载时和子模块加载之前在app.component中执行此操作。
例如,如果www.myapp.com/home加载我想从app.component中的解析路由器获取数据(在ngOnInit中我猜)在submodule.component中没有。
是否可以在app.routers中描述路径,该路径将在app.routers中的其他参数之前加载?
提前致谢!
更新
export const routes: Routes = [
{
path: "login", // to sign in or to see information about current logged user
loadChildren: "app/login/login.module"
},
{
path: "sign-up", // to sing up new users
loadChildren: "app/signup/sign-up.module"
},
{
path: "home", // to see home page
loadChildren: "app/home/home.module"
},
{ // path by default, redirecting to home page
path: "",
redirectTo: "/home",
pathMatch: "full"
},
{ // directory to see, edit, search countries
resolve: {
userData: UserResolve
},
path: "countries",
loadChildren: "app/country/country.module"
},
{ // any other page will redirect to Page404Component component
path: "page404",
loadChildren: "app/404/page404.module"
},
{ // path which doesn"t exist
path: "**",
redirectTo: "/page404",
pathMatch: "full"
}
];