Contrived router example

This commit is contained in:
Max Lynch
2015-06-17 16:03:17 -05:00
parent ff13e9f3b0
commit ebe2a390cc
3 changed files with 10 additions and 5 deletions

View File

@ -1,7 +1,7 @@
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {View} from 'angular2/src/core/annotations_impl/view';
import {Routable, NavController, NavbarTemplate, Navbar, NavPush, Content} from 'ionic/ionic';
import {Routable, Router, NavController, NavbarTemplate, Navbar, NavPush, Content} from 'ionic/ionic';
import {SecondPage} from './second-page';
@ -35,7 +35,7 @@ export class FirstPage {
this.nav = nav;
this.val = Math.round(Math.random() * 8999) + 1000;
FirstPage.router.invoke(this);
this.router = FirstPage.router.invoke(this);
this.pushPage = SecondPage;
this.pushData = {
@ -53,6 +53,7 @@ export class FirstPage {
viewDidEnter() {
console.log('viewDidEnter first page');
Router.emit(this.router.routeInfo.url);
}
viewWillLeave() {

View File

@ -1,7 +1,7 @@
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {View} from 'angular2/src/core/annotations_impl/view';
import {Routable, NavController, NavPop, NavParams, NavbarTemplate, Navbar, Content} from 'ionic/ionic';
import {Routable, Router, NavController, NavPop, NavParams, NavbarTemplate, Navbar, Content} from 'ionic/ionic';
import {ThirdPage} from './third-page';
@ -36,7 +36,7 @@ export class SecondPage {
this.params = params;
this.val = Math.round(Math.random() * 8999) + 1000;
SecondPage.router.invoke(this);
this.router = SecondPage.router.invoke(this);
console.log('Second page params:', params);
}
@ -59,6 +59,7 @@ export class SecondPage {
viewDidEnter() {
console.log('viewDidEnter second page');
Router.emit(this.router.routeInfo.url);
}
viewWillLeave() {

View File

@ -6,6 +6,7 @@
export class RouterController {
constructor() {
this.routes = []
console.log('Router controller built');
}
// Build route params to send to the matching route.
@ -164,8 +165,10 @@ export class Routable {
}
invoke(componentInstance) {
console.log('Routable invoke', componentInstance);
Router.emit(this.routeInfo.url);
return this;
}
}
var Router = new RouterController();