diff --git a/modules/angular2/examples/router/ts/on_activate/index.html b/modules/angular2/examples/router/ts/on_activate/index.html
deleted file mode 100644
index 12badf9ade..0000000000
--- a/modules/angular2/examples/router/ts/on_activate/index.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- Routing Reuse Lifecycle Example
-
-
-
-
-
-
-
-
-
-
- Loading...
-
-
-
-
diff --git a/modules/angular2/examples/router/ts/on_activate/on_activate_example.ts b/modules/angular2/examples/router/ts/on_activate/on_activate_example.ts
index f2a41f6027..47c24bcd09 100644
--- a/modules/angular2/examples/router/ts/on_activate/on_activate_example.ts
+++ b/modules/angular2/examples/router/ts/on_activate/on_activate_example.ts
@@ -8,14 +8,28 @@ import {
APP_BASE_HREF
} from 'angular2/router';
-
// #docregion routerOnActivate
-@Component({selector: 'my-cmp', template: `routerOnActivate: {{log}}
`})
-class MyCmp implements OnActivate {
+@Component({template: `Child`})
+class ChildCmp {
+}
+
+@Component({
+ template: `
+ Parent
()
+ {{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
@@ -24,23 +38,19 @@ class MyCmp implements OnActivate {
@Component({
selector: 'example-app',
template: `
- My App
+ My app
+
`,
directives: [ROUTER_DIRECTIVES]
})
-@RouteConfig([
- {path: '/', component: MyCmp, name: 'HomeCmp'},
- {path: '/:param', component: MyCmp, name: 'ParamCmp'}
-])
-class AppCmp {
+@RouteConfig([{path: '/parent/...', name: 'Parent', component: ParentCmp}])
+export class AppCmp {
}
-
export function main() {
return bootstrap(
AppCmp, [provide(APP_BASE_HREF, {useValue: '/angular2/examples/router/ts/on_activate'})]);
diff --git a/modules/angular2/examples/router/ts/on_activate/on_activate_spec.ts b/modules/angular2/examples/router/ts/on_activate/on_activate_spec.ts
deleted file mode 100644
index ae24f4a507..0000000000
--- a/modules/angular2/examples/router/ts/on_activate/on_activate_spec.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import {verifyNoBrowserErrors, browser} from 'angular2/src/testing/e2e_util';
-import {expect} from 'angular2/testing';
-
-function waitForElement(selector: string) {
- var EC = (protractor).ExpectedConditions;
- // Waits for the element with id 'abc' to be present on the dom.
- browser.wait(EC.presenceOf($(selector)), 20000);
-}
-
-describe('on activate example app', function() {
- afterEach(verifyNoBrowserErrors);
-
- var URL = 'angular2/examples/router/ts/on_activate/';
-
- it('should update the text when navigating between routes', function() {
- browser.get(URL);
- waitForElement('my-cmp');
-
- expect(element(by.css('my-cmp')).getText())
- .toContain('routerOnActivate: Finished navigating from "null" to ""');
-
- element(by.css('#param-link')).click();
- waitForElement('my-cmp');
-
- expect(element(by.css('my-cmp')).getText())
- .toContain('routerOnActivate: Finished navigating from "" to "1"');
-
- browser.navigate().back();
- waitForElement('my-cmp');
-
- expect(element(by.css('my-cmp')).getText())
- .toContain('routerOnActivate: Finished navigating from "1" to ""');
- });
-});