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 {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 {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';
|
import {SecondPage} from './second-page';
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ 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.router = FirstPage.router.invoke(this);
|
||||||
|
|
||||||
this.pushPage = SecondPage;
|
this.pushPage = SecondPage;
|
||||||
this.pushData = {
|
this.pushData = {
|
||||||
@ -53,6 +53,7 @@ export class FirstPage {
|
|||||||
|
|
||||||
viewDidEnter() {
|
viewDidEnter() {
|
||||||
console.log('viewDidEnter first page');
|
console.log('viewDidEnter first page');
|
||||||
|
Router.emit(this.router.routeInfo.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
viewWillLeave() {
|
viewWillLeave() {
|
||||||
|
@ -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 {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';
|
import {ThirdPage} from './third-page';
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ export class SecondPage {
|
|||||||
this.params = params;
|
this.params = params;
|
||||||
this.val = Math.round(Math.random() * 8999) + 1000;
|
this.val = Math.round(Math.random() * 8999) + 1000;
|
||||||
|
|
||||||
SecondPage.router.invoke(this);
|
this.router = SecondPage.router.invoke(this);
|
||||||
|
|
||||||
console.log('Second page params:', params);
|
console.log('Second page params:', params);
|
||||||
}
|
}
|
||||||
@ -59,6 +59,7 @@ export class SecondPage {
|
|||||||
|
|
||||||
viewDidEnter() {
|
viewDidEnter() {
|
||||||
console.log('viewDidEnter second page');
|
console.log('viewDidEnter second page');
|
||||||
|
Router.emit(this.router.routeInfo.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
viewWillLeave() {
|
viewWillLeave() {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
export class RouterController {
|
export class RouterController {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.routes = []
|
this.routes = []
|
||||||
|
console.log('Router controller built');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build route params to send to the matching route.
|
// Build route params to send to the matching route.
|
||||||
@ -164,8 +165,10 @@ export class Routable {
|
|||||||
}
|
}
|
||||||
invoke(componentInstance) {
|
invoke(componentInstance) {
|
||||||
console.log('Routable invoke', componentInstance);
|
console.log('Routable invoke', componentInstance);
|
||||||
Router.emit(this.routeInfo.url);
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var Router = new RouterController();
|
var Router = new RouterController();
|
||||||
|
Reference in New Issue
Block a user