title: Angular2 router navigate in ngOnInit
body: <p>I am using a service data structure <em>SharedDataService</em> to transfer data between components.
  Now, if the data structure is not set because e.g. F5 is pressed, I would like to jump back to another component by using router.navigate in ngOnInit.</p>
  
  <p>I have nested a child component inside a parent component and both have the logic to check for a valid data structure and navigate if not present.</p>
  
  <p>In another case the child component is used alone and they should navigate in this case to a different location.</p>
  
  <p>The problem is that ngOnInit of the child is called despite I route in the parent.
  Then in the child ngOnInit the following error occurs:</p>
  
  <pre><code>TypeError: Cannot read property 'toString' of undefined
  at getPath (create_url_tree.ts:135)
  at createNewSegment (create_url_tree.ts:221)
  at updateSegment (create_url_tree.ts:163)
  at updateSegmentChildren (create_url_tree.ts:174)
  at Object.createUrlTree (create_url_tree.ts:28)
  at Router.createUrlTree (router.ts:221)
  at Router.navigate (router.ts:263)
  at SafeSubscriber.eval [as _next] (conceptversion.component.ts:48)
  at SafeSubscriber.__tryOrSetError (Subscriber.ts:249)
  at SafeSubscriber.next (Subscriber.ts:193)
  </code></pre>
  
  <p>I tried to create a plunker, but the problem is that I don't know how to include the router from "@angular/router". Maybe you could already see what I am trying to do.</p>
  
  <p><a href="http://plnkr.co/edit/oyrSbW6jYhVOsjnp0MHv?p=preview" rel="nofollow">http://plnkr.co/edit/oyrSbW6jYhVOsjnp0MHv?p=preview</a></p>