mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 11:41:20 +08:00
Contrived router example
This commit is contained in:
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user