I am new to angular 5. And I know very basic routing.So please help me with this problem.I have downloaded ngx-admin from https://github.com/akveo/nebular and now I want to make login page for it , which will come first when user will hit the url.I tried this but is is not working,this is app-routing.module.ts
import { ExtraOptions, RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';
import {
NbAuthComponent,
NbLoginComponent,
NbLogoutComponent,
NbRegisterComponent,
NbRequestPasswordComponent,
NbResetPasswordComponent,
} from '@nebular/auth';
import { LoginComponent } from './login/login.component';
const routes: Routes = [
{path : '' , component: LoginComponent},
{ path: 'pages', loadChildren: 'app/pages/pages.module#PagesModule' },
{
path: 'auth',
component: NbAuthComponent,
children: [
{
path: '',
component: NbLoginComponent,
},
{
path: 'login',
component: NbLoginComponent,
},
{
path: 'register',
component: NbRegisterComponent,
},
{
path: 'logout',
component: NbLogoutComponent,
},
{
path: 'request-password',
component: NbRequestPasswordComponent,
},
{
path: 'reset-password',
component: NbResetPasswordComponent,
},
],
},
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: '**', redirectTo: 'pages' },
];
const config: ExtraOptions = {
useHash: true,
};
@NgModule({
imports: [RouterModule.forRoot(routes, config)],
exports: [RouterModule],
})
export class AppRoutingModule {
}
And this is page-routing.module.ts
import { RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';
import { PagesComponent } from './pages.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { ManageComponent } from './manage/manage.component';
import { UserComponent } from './user/user.component';
const routes: Routes = [{
// path: '/home',
path:'',
component: PagesComponent,
children: [{
path: 'dashboard',
component: DashboardComponent,
}, {
path: 'ui-features',
loadChildren: './ui-features/ui-features.module#UiFeaturesModule',
},
{
path: 'add-booking',
loadChildren: './add-booking/addbooking.module#AddbookingModule',
},{
path: 'components',
loadChildren: './components/components.module#ComponentsModule',
}, {
path: 'maps',
loadChildren: './maps/maps.module#MapsModule',
}, {
path: 'charts',
loadChildren: './charts/charts.module#ChartsModule',
}, {
path: 'editors',
loadChildren: './editors/editors.module#EditorsModule',
}, {
path: 'forms',
loadChildren: './forms/forms.module#FormsModule',
}, {
path: 'tables',
loadChildren: './tables/tables.module#TablesModule',
},
{
path: 'manage',
component: ManageComponent,
},
{
path: 'user',
component: UserComponent,
},{
path: '',
redirectTo: 'dashboard',
pathMatch: 'full',
}],
}];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class PagesRoutingModule {
}
try changing the redirectTo in app-routing.module.ts: redirectTo: 'auth/login'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With