Guest User

Untitled

a guest
Dec 14th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import {Component} from '@angular/core'
  2.  
  3. @Component({
  4. selector: 'my-app',
  5. template: `
  6. <router-outlet></router-outlet>
  7. `,
  8. })
  9. export class AppComponent {
  10. constructor() { }
  11. }
  12.  
  13. import {NgModule} from '@angular/core'
  14. import {BrowserModule} from '@angular/platform-browser'
  15. import {RouterModule} from '@angular/router'
  16.  
  17. import { AppComponent } from './app.component'
  18. import {Home} from './home.component'
  19. import {Dashboard} from './dashboard.component'
  20. import {Contact} from './contact.component'
  21.  
  22. @NgModule({
  23. imports: [ BrowserModule,
  24. RouterModule.forRoot([
  25. {path: 'home', component: Home},
  26. {path: 'dashboard', component: Dashboard},
  27. {path: 'contact', component: Contact},
  28. {path: '', redirectTo: '/home', pathMatch: 'full'}
  29. ])],
  30. declarations: [ AppComponent, Home, Dashboard, Contact ],
  31. bootstrap: [ AppComponent ]
  32. })
  33. export class AppModule {}
  34.  
  35. import {Component} from '@angular/core'
  36.  
  37. @Component({
  38. template: `
  39. <h2>Home</h2>
  40. <nav>
  41. <a routerLink="/dashboard">Dashboard</a>
  42. <a routerLink="/contact">Contact</a>
  43. </nav>
  44. <router-outlet></router-outlet>
  45. `,
  46. })
  47. export class Home {
  48. constructor() { }
  49. }
Add Comment
Please, Sign In to add comment