有一些問題,我的angular2路由我無法弄清楚,我採取「本地主機:3000」我的瀏覽器我得到兩個應用程序,再次應用程序被加載我的router-outlet.Can有人可以幫我解決這個問題?
app.routing.ts
import { ModuleWithProviders } from '@angular/core';
import { RouterModule, Routes, CanActivate } from '@angular/router';
import { AuthGuard } from './services/auth-guard.service';
import {AppComponent} from './app.component';
const routes: Routes = [
{
path: '', component: AppComponent,
children:[
{ path: 'login',loadChildren: './components/login/login.module#LoginModule'},
{ path: 'reset-password', loadChildren: './components/password-reset/reset-password.module#ResetPasswordModule'},
{ path: 'app',loadChildren: './components/app-holder/app-holder.module#AppHolderModule' },
]
}
];
export const Routing: ModuleWithProviders = RouterModule.forRoot(routes);
app.component.html
<header></header>
<div class="app-container">
<router-outlet></router-outlet>
</div>
<footer></footer>
APP-holder.routing.ts
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppHolderComponent } from './app-holder.component';
const routes: Routes = [
{
path: '', component: AppHolderComponent
}
];
export const AppHolderRoutes: ModuleWithProviders = RouterModule.forChild(routes);
login.routing.ts
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login.component';
const routes: Routes = [
{ path: '', component: LoginComponent }
];
export const LoginRoutes: ModuleWithProviders = RouterModule.forChild(routes);
密碼reset.routing.ts
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PasswordResetComponent } from './reset-password.component';
const routes: Routes = [
{ path: '', component: PasswordResetComponent }
];
export const LoginRoutes: ModuleWithProviders = RouterModule.forChild(routes);
什麼是appHolderComponent?發佈代碼 – Sajeetharan
appholder只是您登錄時看到的一個組件,到目前爲止還沒有任何內容。問題是我可以看到兩個標題。 – RemyaJ
只需將默認組件更改爲登錄而不是appcomponent, – Sajeetharan