Guest User

Untitled

a guest
Jan 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. imports: [
  2. BrowserModule,
  3. RouterModule.forRoot([
  4. {
  5. path: '',
  6. component: HomeComponent,
  7. data: {
  8. title: 'Home'
  9. }
  10. },
  11. {
  12. path: 'about',
  13. component: AboutComponent,
  14. data: {
  15. title: 'About'
  16. }
  17. },
  18. {
  19. path: 'products-and-services',
  20. component: ProductsServicesComponent,
  21. data: {
  22. title: 'Products & Services'
  23. }
  24. },
  25. {
  26. path: 'world-class-laundry',
  27. component: LaundryComponent,
  28. data: {
  29. title: 'World Class Laundry'
  30. }
  31. },
  32. {
  33. path: 'contact',
  34. component: ContactComponent,
  35. data: {
  36. title: 'Contact'
  37. }
  38. },
  39. {
  40. path: '**',
  41. component: NotFoundComponent,
  42. data: {
  43. title: 'Page Not Found'
  44. }
  45. }
  46. ])
  47. ],
  48.  
  49. ngOnInit() {
  50. this.router.events
  51. .filter((event) => event instanceof NavigationEnd)
  52. .map(() => this.activatedRoute)
  53. .map((route) => {
  54. while (route.firstChild) route = route.firstChild;
  55. return route;
  56. })
  57. .filter((route) => route.outlet === 'primary')
  58. .mergeMap((route) => route.data)
  59. .subscribe((event) => {
  60. this.titleService.setTitle(event['title']);
  61. });
  62. }
Add Comment
Please, Sign In to add comment