首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在ngx-admin nebular中制作登录页面

如何在ngx-admin nebular中制作登录页面
EN

Stack Overflow用户
提问于 2018-02-02 17:48:11
回答 2查看 7.3K关注 0票数 5

我是angular 5的新手。我知道非常基本的管理员,请帮助我解决这个问题。我已经从https://github.com/akveo/nebular下载了ngx- routing.So,现在我想为它制作登录页面,当用户点击url.I时,登录页面将首先出现。我尝试过这个,但它不起作用,这是应用路由。模块

代码语言:javascript
运行
复制
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 {
}

这是page-routing.module.ts

代码语言:javascript
运行
复制
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 {
}
EN

回答 2

Stack Overflow用户

发布于 2018-04-01 15:53:53

尝试更改app-routing.module.ts中的登录: redirectTo:‘auth/ redirectTo’

票数 1
EN

Stack Overflow用户

发布于 2018-05-31 16:20:51

嘿,把它改成这样

代码语言:javascript
运行
复制
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' },
];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48579902

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档