Last active
November 10, 2018 07:22
-
-
Save yujiokayama/3167f9a63e5f1c6ea274f6465e707ca9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1.routing-moduleを作成 | |
| CLI command | |
| ng g module app-routing --flat --module=app | |
| 2.AppRoutingModuleを編集 | |
| import { NgModule } from '@angular/core'; | |
| import { CommonModule } from '@angular/common'; | |
| import { RouterModule, Routes } from '@angular/router'; | |
| //必要なコンポーネントをインポート | |
| const routes: Routes = [ | |
| { path: '', component: ChatComponent }, //初期表示 | |
| { path: 'users', loadChildren: './users/users.module#UsersModule' }, | |
| { path: '**', component: NotFoundComponent }, //ワイルドカード(該当しないURLの時) | |
| ]; | |
| @NgModule({ | |
| imports: [ | |
| CommonModule, | |
| RouterModule.forRoot(routes) | |
| ], | |
| exports: [ | |
| RouterModule | |
| ], | |
| declarations: [] | |
| }) | |
| export class AppRoutingModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment