import {APP_BASE_HREF} from '@angular/common'; import {Component, ComponentRef, provide} from '@angular/core'; import {bootstrap} from '@angular/platform-browser-dynamic'; import {ComponentInstruction, OnActivate, ROUTER_DIRECTIVES, RouteConfig} from '@angular/router-deprecated'; // #docregion routerOnActivate @Component({template: `Child`}) class ChildCmp { } @Component({ template: `
{{log}}
`, directives: [ROUTER_DIRECTIVES] }) @RouteConfig([{path: '/child', name: 'Child', component: ChildCmp}]) class ParentCmp implements OnActivate { log: string = ''; routerOnActivate(next: ComponentInstruction, prev: ComponentInstruction) { this.log = `Finished navigating from "${prev ? prev.urlPath : 'null'}" to "${next.urlPath}"`; return new Promise(resolve => { // The ChildCmp gets instantiated only when the Promise is resolved setTimeout(() => resolve(null), 1000); }); } } // #enddocregion @Component({ selector: 'example-app', template: `