Skip to content

Instantly share code, notes, and snippets.

@elcodabra
Created September 20, 2017 12:51
Show Gist options
  • Save elcodabra/de082cabd7be63f0ae44866bc8777b75 to your computer and use it in GitHub Desktop.
Save elcodabra/de082cabd7be63f0ae44866bc8777b75 to your computer and use it in GitHub Desktop.
@angular/router
<div class="container">
<div class="starter-template">
<!-- ... -->
<router-outlet></router-outlet>
</div>
</div>
// ...
import { RoutingModule } from './routing.module';
@NgModule({
declarations: [
...
],
imports: [
RoutingModule,
...
],
providers: [ ... ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
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