title: How can I get the value of ActivatedRoute in Ionic 4?
body: <p>I have two pages that require authentication, so I've created an <code>AuthGuard</code> that will redirect to a login form when an un-authenticated user hits that route. This is working perfectly, however, I would like to set it up so that the user is redirected to the page they were initially trying to access.</p>
  
  <p>I've added <code>data</code> to my route, so that I can pass a <code>page</code> parameter, and then redirect to the appropriate page after login. This is not working, as I can not get the contents of <code>data</code>; most attempts have resulted in an error. What I have below does not error, however it doesn't work either as <code>data</code> comes back empty <code>{}</code></p>
  
  <h2>app-routing-module.ts</h2>
  
  <pre><code>const routes: Routes = [
      {
          path: 'map',
          loadChildren: './map/map.module#MapPageModule',
          canActivate: [AuthGuard],
          data: {
              page: 'map'
          }
      },
      {
          path: 'collections',
          loadChildren: './collections/collections.module#CollectionsPageModule',
          canActivate: [AuthGuard],
          data: {
              page: 'collections'
          }
      },
  ];
  </code></pre>
  
  <h3>login.page.ts</h3>
  
  <pre><code>import { Router, ActivatedRoute } from '@angular/router';
  
  constructor(
      private activatedRoute: ActivatedRoute
  ) {}
  
  login(formData: any) {
      ...
  
      if(this.activatedRoute.snapshot.data.page === 'map') {
          this.router.navigate(['/map']);
      }
  
      ...
  }
  </code></pre>
  
  <p>When I log the following I get <code>undefined</code></p>
  
  <pre><code>console.log(this.activatedRoute.snapshot.data.page);
  </code></pre>
  
  <p>How can I get the contents of <code>data</code> so I can see the page value?</p>