作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 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 {
}
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/
我是一名优秀的程序员,十分优秀!