Can anybody help me please with resolve router question.
I have one main module "app.module" which consists of few submodules. App.module has app.routers file which describes lazy loading for its submodules.
The file app.routers looks like this:
..
{
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
..
I want to use resolve router to load some data from server and I want to do it in app.component when app.component is loading and before submodules load.
For example if www.myapp.com/home loads I want to get data from resolve router in app.component (in ngOnInit I guess) no in submodule.component.
Is it possible to describe path in app.routers which will load before another statments in app.routers?
Thanks in advance!
Updated
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"
}
];