Routing emit

This commit is contained in:
Max Lynch
2015-06-17 10:00:19 -05:00
parent c85273e43f
commit d509ef4d5a
2 changed files with 14 additions and 2 deletions

View File

@ -1,7 +1,7 @@
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations'; import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {View} from 'angular2/src/core/annotations_impl/view'; import {View} from 'angular2/src/core/annotations_impl/view';
import {NavController, NavbarTemplate, Navbar, NavPush, Content} from 'ionic/ionic'; import {Routable, NavController, NavbarTemplate, Navbar, NavPush, Content} from 'ionic/ionic';
import {SecondPage} from './second-page'; import {SecondPage} from './second-page';
@ -35,6 +35,8 @@ export class FirstPage {
this.nav = nav; this.nav = nav;
this.val = Math.round(Math.random() * 8999) + 1000; this.val = Math.round(Math.random() * 8999) + 1000;
FirstPage.router.invoke(this);
this.pushPage = SecondPage; this.pushPage = SecondPage;
this.pushData = { this.pushData = {
id: 420 id: 420
@ -81,3 +83,7 @@ export class FirstPage {
this.nav.push(SecondPage, { id: 8675309, myData: [1,2,3,4] }, { animation: 'ios' }); this.nav.push(SecondPage, { id: 8675309, myData: [1,2,3,4] }, { animation: 'ios' });
} }
} }
new Routable(FirstPage, {
url: '/first-page'
})

View File

@ -158,7 +158,13 @@ export class Routable {
this.componentClass = componentClass; this.componentClass = componentClass;
this.routeInfo = routeInfo; this.routeInfo = routeInfo;
componentClass._route = this; console.log('New routable', componentClass, routeInfo);
componentClass.router = this;
}
invoke(componentInstance) {
console.log('Routable invoke', componentInstance);
Router.emit(this.routeInfo.url);
} }
} }