title: How to get data from Route or ActivatedRoute when subscribing to router.events.subscribe in Angular2?
body: <p>I'm trying to get the data from a Router whenever the Route changes but I'm not having success. Here I set the <code>asdf</code> property</p>
  
  <pre><code>@NgModule({
    bootstrap: [AppComponent],
    declarations: [
      AppComponent,
      LoginComponent,
      DashboardComponent,
      OverviewComponent,
    ],
    imports: [
      BrowserModule,
      FormsModule,
      RouterModule.forRoot([
        { path: '', pathMatch: 'full', redirectTo: '' },
        { component: LoginComponent, path: 'login' },
        {
          children: [
            { path: '', pathMatch: 'full', redirectTo: 'overview', data: { asdf: 'hello' } },
            { component: OverviewComponent, path: 'overview', data: { asdf: 'hello' } },
          ], component: DashboardComponent,
          path: '',
        },
      ]),
    ],
  })
  export class AppModule { }
  </code></pre>
  
  <p>And here I can get the URL from the router when the route changes but <code>asdf</code> is undefined :(</p>
  
  <pre><code>import { Component, OnDestroy, OnInit } from '@angular/core';
  import { Router } from '@angular/router';
  import { ActivatedRoute, NavigationEnd } from '@angular/router';
  @Component({
    selector: 'cs-map',
    styleUrls: ['map.component.css'],
    templateUrl: 'map.component.html',
  })
  export class MapComponent implements OnInit {
    private routerSub;
  
    constructor(private router: Router, private activatedRoute: ActivatedRoute) { }
  
    public ngOnInit() {
      this.router.events.subscribe((val) =&gt; {
        if (val instanceof NavigationEnd) {
          let url = val.url;
          console.log(this.activatedRoute.snapshot.data['asdf']); // data is defined but asdf is not :(
        }
      });
    }
  }
  </code></pre>
  
  <p>How can I get <code>asdf</code>'s value?</p>
  
  <p>Edit: I'm navigating to <code>/overview</code></p>