title: Using switchMap with Promises
body: <p>I am learning Angular2, following the "Tour of Heroes" tutorial on Angular.io.  Near the end of the tutorial, we set up routing to a detail page and pass a parameter indicating the hero to displace.  This is handled using the params Observable in ActivatedRoute.  We use switchMap to redirect from the params Observable to a Promise to return the data we actually want based on the parameter.</p>
  
  <p>The syntax used in the tutorial is concise, so I tried to break it out into building blocks to get a better understanding of what is going on.  Specifically, I have tried to replace <strong>right arrow notation</strong> with an actual function, that I think is identical.  But my modification does not work.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>ngOnInit(): void {
          this.route.params
          .switchMap((params: Params) =&gt; this.heroService.getHero(+params['id']))
          //.switchMap(this.getHero)
          .subscribe(hero =&gt; this.hero = hero);
      }
  
      getHero(params: Params) : Promise&lt;Hero&gt; {
          return this.heroService.getHero(+params['id']);
      }
  </code></pre>
  
  <p>What confuses me is why using the line that is currently commented out instead of the line above it, I get an error: <code>"Cannot read property 'getHero' of undefined."</code>  The two versions of code look identical to me.</p>