mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
@ -106,11 +106,8 @@ import {ViewController} from './view-controller';
|
|||||||
template: '<div #contents></div>'
|
template: '<div #contents></div>'
|
||||||
})
|
})
|
||||||
export class Nav extends NavController {
|
export class Nav extends NavController {
|
||||||
|
private _root: Type;
|
||||||
/**
|
private _hasInit: boolean = false;
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
@Input() root: Type;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Optional() hostNavCtrl: NavController,
|
@Optional() hostNavCtrl: NavController,
|
||||||
@ -134,15 +131,32 @@ export class Nav extends NavController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @input {Page} The Page component to load as the root page within this nav.
|
||||||
|
*/
|
||||||
|
@Input()
|
||||||
|
get root(): Type {
|
||||||
|
return this._root;
|
||||||
|
}
|
||||||
|
set root(page: Type) {
|
||||||
|
this._root = page;
|
||||||
|
|
||||||
|
if (this._hasInit) {
|
||||||
|
this.setRoot(page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.root) {
|
this._hasInit = true;
|
||||||
if (typeof this.root !== 'function') {
|
|
||||||
|
if (this._root) {
|
||||||
|
if (typeof this._root !== 'function') {
|
||||||
throw 'The [root] property in <ion-nav> must be given a reference to a component class from within the constructor.';
|
throw 'The [root] property in <ion-nav> must be given a reference to a component class from within the constructor.';
|
||||||
}
|
}
|
||||||
this.push(this.root);
|
this.push(this._root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
ionic/components/nav/test/init-async/index.ts
Normal file
26
ionic/components/nav/test/init-async/index.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import {App, Page} from 'ionic-angular';
|
||||||
|
|
||||||
|
|
||||||
|
@Page({
|
||||||
|
template: `
|
||||||
|
<ion-content padding text-center>
|
||||||
|
Page be loaded!
|
||||||
|
</ion-content>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
class AsyncPage {}
|
||||||
|
|
||||||
|
|
||||||
|
@App({
|
||||||
|
template: `<ion-nav [root]="root"></ion-nav>`
|
||||||
|
})
|
||||||
|
class E2EApp {
|
||||||
|
root;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.root = AsyncPage;
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user