如何在ngx-admin nebular中创建登录页面

时间:2018-02-02 09:48:11

标签: angular routing

我是角色5的新手。我知道非常基本的路由。所以请帮助我解决这个问题。我从https://github.com/akveo/nebular下载了ngx-admin,现在我想为它创建登录页面,这将是当用户点击url时我会先来。我试过这个但是没有用,这是app-routing.module.ts

<p><svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1113 974q13 0 97.5 44t89.5 53q2 5 2 15 0 33-17 76-16 39-71 65.5t-102 26.5q-57 0-190-62-98-45-170-118t-148-185q-72-107-71-194v-8q3-91 74-158 24-22 52-22 6 0 18 1.5t19 1.5q19 0 26.5 6.5t15.5 27.5q8 20 33 88t25 75q0 21-34.5 57.5t-34.5 46.5q0 7 5 15 34 73 102 137 56 53 151 101 12 7 22 7 15 0 54-48.5t52-48.5zm-203 530q127 0 243.5-50t200.5-134 134-200.5 50-243.5-50-243.5-134-200.5-200.5-134-243.5-50-243.5 50-200.5 134-134 200.5-50 243.5q0 203 120 368l-79 233 242-77q158 104 345 104zm0-1382q153 0 292.5 60t240.5 161 161 240.5 60 292.5-60 292.5-161 240.5-240.5 161-292.5 60q-195 0-365-94l-417 134 136-405q-108-178-108-389 0-153 60-292.5t161-240.5 240.5-161 292.5-60z"/></svg> Whatsapp
</p>

这是page-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 {
}

2 个答案:

答案 0 :(得分:0)

尝试在app-routing.module.ts中更改redirectTo: redirectTo:&#39; auth / login&#39;

答案 1 :(得分:0)

嘿把它改成这样

App-routing.module.ts

const routes: Routes = [
  { path: 'pages', loadChildren: 'app/pages/pages.module#PagesModule' },
  {
    path: '',
    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: 'pages', pathMatch: 'full' },
  { path: '**', redirectTo: 'pages' },
];