別のコンポーネントが表示され、ここではスクリプトです:角度2子ルートモジュールは、正しいURLを表示するが、ルートの子カスタムモジュールを作成することによって、私は私のルートルートファイルをクリーンアップ
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { SigninComponent } from './signin/signin.component';
import { SignupComponent } from './signup/signup.component';
const childRoutes: Routes = [
{path: 'signin', component: SigninComponent},
{path: 'signup', component: SignupComponent}
];
@NgModule({
imports: [
RouterModule.forChild(childRoutes)
],
exports:[RouterModule]
})
export class ChildRoutingModule { }
ルートルートモジュール今ある:
import ...
import ...
import { AppRoutingModule } from './routes'
import { ChildRoutingModule } from './auth/auth.route'
@NgModule({
declarations: [
AppComponent
],
imports: [
AppRoutingModule,
ChildRoutingModule,
BrowserModule,
AuthModule,
RouterModule
],
providers: [AuthService],
bootstrap: [AppComponent]
})
export class AppModule { }
PROB:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { SigninComponent } from './auth/signin/signin.component';
import { SignupComponent } from './auth/signup/signup.component';
import { NotfoundComponent } from './notfound/notfound.component';
import { ChildRoutingModule } from './auth/auth.route'
const appRoutes: Routes = [
{path: '', redirectTo:'/signup', pathMatch:'full'},
{path: '**', component: NotfoundComponent}
];
@NgModule({
imports: [
RouterModule.forRoot(appRoutes)
],
exports:[RouterModule]
})
export class AppRoutingModule { }
は私がapp.module.tsに2つのルートモジュールをインポートLEMは今URLが正しい、サインアップコンポーネントでアプリの起動コンポーネントである:
http://localhost:4200/signup
が、表示されたコンポーネントは、エラーなしていることを言及するには
{path: '**', component: NotfoundComponent}
により、ルート、ルート要素で定義されている404のコンポーネントでありますコンソールにはすべて表示されます
代わりのredirectTo: '/サインアップ'、 使用redirectTo: 'サインアップ'、 、再試行してください。 –
輸入:[ BrowserModule、 AuthModule、 RouterModule、 ChildRoutingModule、 AppRoutingModule、 ]、 – droidnation
。それはうまくいったが、なぜ私は最後にルートルートモジュールをインポートする必要があります –