gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 11:42:18 30 4
gpt4 key购买 nike

我是 angular 5 的新手。我知道非常基本的路由。所以请帮我解决这个问题。我已经从 https://github.com/akveo/nebular 下载了 ngx-admin现在我想为它制作登录页面,当用户点击 url 时它会首先出现。我试过这个但不起作用,这是 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 {
}

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

最佳答案

尝试更改 app-routing.module.ts 中的 redirectTo:
重定向到:'身份验证/登录'

关于angular - 如何在 ngx-admin nebular 中制作登录页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48579902/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com