Async load routes data and build route instruction for Angular 2
<p>I try to build dynamically routes from angular2 (fetch route config from server), after that I parse it and generate instruction for component route (I have parent routes config and child into different components, because I don`t know how define route for child component into   one  main.app.ts file).</p>

<p>The problem is when app started and try to create routes config and routeGenerator is not build routes yet (async delay) can<code>t parse routes data (because  async delay, so  routesData undefined now)   and app is crashig. I don</code>t know what to do with this. Looking for  lifecycle hood (some like - @Angular2BeforeAppStarted  )  but found nothing.</p>

<pre><code>    import {Component, Input, OnChanges} from 'angular2/core';
import {RouteConfig, RouterOutlet, ROUTER_DIRECTIVES, Router} from 'angular2/router';
/* ------- !Angular 2 native components  ---------*/
import {routeGenInstance} from '../../config/routes/patient_routes';


protected const BUILT_MODULE_PATH: string = '/built/modules/patients/';

@Component({
  template: `
    &lt;router-outlet &gt;&lt;/router-outlet&gt;
  `,
  directives: [RouterOutlet, ROUTER_DIRECTIVES]
})
@RouteConfig(routeGenInstance.getRouteDefinitions())

export class PatientsComponent {
  @Input();

  constructor() {}

}
</code></pre>

<p>Also i try to update routes in the same way  (but app is crashed immediately because my Navigation link in navigation component is not have some correct link way)</p>

<pre><code>import {RouteConfig, RouterOutlet, ROUTER_DIRECTIVES, Router} from 'angular2/router';

     constructor(
        private router: Router
         ) {
        router.config([
             routeGenInstance.getRoutesDefinition()
        ])
      }
</code></pre>

<p>my route definitions use Async loader so they are correct and work whithout async delay. I don`t know how to make angular wait for my routes definitions and thet start to run the app.</p>

<p>Please, help me. Thanks.</p>

<p><strong>UPD:</strong></p>

<p>@Thierry many thanks for your help again. You are awesome my friend and mentor. One last question (last).  Can you tell me how I can define routeConfig  into one app file  with child subrouting definition?
Its mean.  I have main level routes into app files</p>

<pre><code>{
  path: '/',
  name: 'Dashboard',
  component: DashboardComponent,
  useAsDefault: true
},
{
  path: '/patients/...',
  name: 'Patients',
  component: PatientsComponent
},
</code></pre>

<p>and patient sub routes  into patientsComponent  (@RouteConfig)</p>

<pre><code>{
  path: '/',      // root is appRoot/patients/...
  name: 'PatientsList', component...},
  {
  "name": "Chart",
  "path": "/chart/:id", component...
},
</code></pre>

<p>How to define this route config only into one app.file ?  (How to configure route with  sub routing in one file)?    </p>