Created
September 20, 2017 12:51
-
-
Save elcodabra/de082cabd7be63f0ae44866bc8777b75 to your computer and use it in GitHub Desktop.
@angular/router
This file contains 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
<div class="container"> | |
<div class="starter-template"> | |
<!-- ... --> | |
<router-outlet></router-outlet> | |
</div> | |
</div> |
This file contains 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
// ... | |
import { RoutingModule } from './routing.module'; | |
@NgModule({ | |
declarations: [ | |
... | |
], | |
imports: [ | |
RoutingModule, | |
... | |
], | |
providers: [ ... ], | |
bootstrap: [ AppComponent ] | |
}) | |
export class AppModule { } |
This file contains 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
import { NgModule } from '@angular/core'; | |
import { RouterModule, Routes } from '@angular/router'; | |
import { AboutComponent } from './components/about/about.component'; | |
import { HomeComponent } from './components/home/home.component'; | |
import { PageNotFoundComponent } from './components/page-not-found/page-not-found.component'; | |
import { ListTweetsComponent } from './components/tweets/list/tweets-list.component'; | |
const routes: Routes = [ | |
{ path: 'about', component: AboutComponent }, | |
{ path: 'home', component: HomeComponent }, | |
{ path: 'tweets', component: ListTweetsComponent }, | |
{ path: '', redirectTo: '/tweets', pathMatch: 'full' }, | |
{ path: '**', component: PageNotFoundComponent }, | |
]; | |
@NgModule({ | |
imports: [ RouterModule.forRoot(routes, { useHash: true }) ], | |
exports: [ RouterModule ] | |
}) | |
export class RoutingModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment