mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +08:00
fix(nav): register child nav when created from modal
This commit is contained in:
@ -5,7 +5,7 @@ import { ActionSheetController, App, Config, ionicBootstrap, ModalController, Na
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
class SomeComponentProvider {
|
class SomeComponentProvider {
|
||||||
constructor(private config: Config) {
|
constructor(public config: Config) {
|
||||||
console.log('SomeComponentProvider constructor');
|
console.log('SomeComponentProvider constructor');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ class SomeComponentProvider {
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
class SomeAppProvider {
|
class SomeAppProvider {
|
||||||
constructor(private config: Config) {
|
constructor(public config: Config) {
|
||||||
console.log('SomeAppProvider constructor');
|
console.log('SomeAppProvider constructor');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ class SomeAppProvider {
|
|||||||
class E2EPage {
|
class E2EPage {
|
||||||
platforms: string[];
|
platforms: string[];
|
||||||
|
|
||||||
constructor(private nav: NavController, private modalCtrl: ModalController, config: Config, platform: Platform) {
|
constructor(public navCtrl: NavController, public modalCtrl: ModalController, config: Config, platform: Platform) {
|
||||||
console.log('platforms', platform.platforms());
|
console.log('platforms', platform.platforms());
|
||||||
console.log('mode', config.get('mode'));
|
console.log('mode', config.get('mode'));
|
||||||
|
|
||||||
@ -117,11 +117,10 @@ class E2EPage {
|
|||||||
`
|
`
|
||||||
})
|
})
|
||||||
class NavigableModal {
|
class NavigableModal {
|
||||||
constructor(private nav: NavController) {
|
constructor(public navCtrl: NavController) {}
|
||||||
}
|
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
this.nav.push(NavigableModal2);
|
this.navCtrl.push(NavigableModal2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +138,7 @@ class NavigableModal {
|
|||||||
`
|
`
|
||||||
})
|
})
|
||||||
class NavigableModal2 {
|
class NavigableModal2 {
|
||||||
constructor(private navController: NavController) {
|
constructor(public navController: NavController) {
|
||||||
}
|
}
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
@ -175,7 +174,7 @@ class NavigableModal2 {
|
|||||||
class ModalPassData {
|
class ModalPassData {
|
||||||
data: any;
|
data: any;
|
||||||
|
|
||||||
constructor(params: NavParams, private viewCtrl: ViewController, someComponentProvider: SomeComponentProvider, someAppProvider: SomeAppProvider) {
|
constructor(params: NavParams, public viewCtrl: ViewController, someComponentProvider: SomeComponentProvider, someAppProvider: SomeAppProvider) {
|
||||||
this.data = {
|
this.data = {
|
||||||
userId: params.get('userId'),
|
userId: params.get('userId'),
|
||||||
name: someComponentProvider.getName()
|
name: someComponentProvider.getName()
|
||||||
@ -245,7 +244,7 @@ class ModalPassData {
|
|||||||
})
|
})
|
||||||
class ToolbarModal {
|
class ToolbarModal {
|
||||||
|
|
||||||
constructor(private viewCtrl: ViewController) {}
|
constructor(public viewCtrl: ViewController) {}
|
||||||
|
|
||||||
dismiss() {
|
dismiss() {
|
||||||
this.viewCtrl.emit({
|
this.viewCtrl.emit({
|
||||||
@ -294,7 +293,7 @@ class ToolbarModal {
|
|||||||
class ModalWithInputs {
|
class ModalWithInputs {
|
||||||
data: any;
|
data: any;
|
||||||
|
|
||||||
constructor(private viewCtrl: ViewController) {
|
constructor(public viewCtrl: ViewController) {
|
||||||
this.data = {
|
this.data = {
|
||||||
title: 'Title',
|
title: 'Title',
|
||||||
note: 'Note',
|
note: 'Note',
|
||||||
@ -374,11 +373,10 @@ class ContactUs {
|
|||||||
`
|
`
|
||||||
})
|
})
|
||||||
class ModalFirstPage {
|
class ModalFirstPage {
|
||||||
|
items: any[] = [];
|
||||||
|
|
||||||
private items: any[];
|
constructor(public navCtrl: NavController, public app: App, public actionSheetCtrl: ActionSheetController) {
|
||||||
constructor(private nav: NavController, private app: App, private actionSheetCtrl: ActionSheetController) {
|
for (let i = 0; i < 50; i++) {
|
||||||
this.items = [];
|
|
||||||
for ( let i = 0; i < 50; i++ ) {
|
|
||||||
this.items.push({
|
this.items.push({
|
||||||
value: (i + 1)
|
value: (i + 1)
|
||||||
});
|
});
|
||||||
@ -389,11 +387,11 @@ class ModalFirstPage {
|
|||||||
let page = ModalSecondPage;
|
let page = ModalSecondPage;
|
||||||
let params = { id: 8675309, myData: [1, 2, 3, 4] };
|
let params = { id: 8675309, myData: [1, 2, 3, 4] };
|
||||||
|
|
||||||
this.nav.push(page, params);
|
this.navCtrl.push(page, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
dismiss() {
|
dismiss() {
|
||||||
this.app.getRootNav().pop();
|
this.navCtrl.parent.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
ionViewLoaded() {
|
ionViewLoaded() {
|
||||||
@ -465,7 +463,7 @@ class ModalFirstPage {
|
|||||||
</ion-header>
|
</ion-header>
|
||||||
<ion-content padding>
|
<ion-content padding>
|
||||||
<p>
|
<p>
|
||||||
<button (click)="nav.pop()">Pop (Go back to 1st)</button>
|
<button (click)="navCtrl.pop()">Pop (Go back to 1st)</button>
|
||||||
</p>
|
</p>
|
||||||
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
|
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
|
||||||
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
|
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
|
||||||
@ -473,7 +471,7 @@ class ModalFirstPage {
|
|||||||
`
|
`
|
||||||
})
|
})
|
||||||
class ModalSecondPage {
|
class ModalSecondPage {
|
||||||
constructor(private nav: NavController, params: NavParams) {
|
constructor(public navCtrl: NavController, params: NavParams) {
|
||||||
console.log('Second page params:', params);
|
console.log('Second page params:', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,9 +81,15 @@ export class Nav extends NavControllerBase implements AfterViewInit {
|
|||||||
// this Nav has a parent Nav
|
// this Nav has a parent Nav
|
||||||
parent.registerChildNav(this);
|
parent.registerChildNav(this);
|
||||||
|
|
||||||
} else if (app) {
|
} else if (viewCtrl && viewCtrl.getNav()) {
|
||||||
|
// this Nav was opened from a modal
|
||||||
|
this.parent = viewCtrl.getNav();
|
||||||
|
this.parent.registerChildNav(this);
|
||||||
|
|
||||||
|
} else if (app && !app.getRootNav()) {
|
||||||
|
// a root nav has not been registered yet with the app
|
||||||
// this is the root navcontroller for the entire app
|
// this is the root navcontroller for the entire app
|
||||||
this._app.setRootNav(this);
|
app.setRootNav(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +274,11 @@ export class Tabs extends Ion {
|
|||||||
// this Tabs has a parent Nav
|
// this Tabs has a parent Nav
|
||||||
this.parent.registerChildNav(this);
|
this.parent.registerChildNav(this);
|
||||||
|
|
||||||
|
} else if (viewCtrl && viewCtrl.getNav()) {
|
||||||
|
// this Nav was opened from a modal
|
||||||
|
this.parent = <any>viewCtrl.getNav();
|
||||||
|
this.parent.registerChildNav(this);
|
||||||
|
|
||||||
} else if (this._app) {
|
} else if (this._app) {
|
||||||
// this is the root navcontroller for the entire app
|
// this is the root navcontroller for the entire app
|
||||||
this._app.setRootNav(this);
|
this._app.setRootNav(this);
|
||||||
@ -375,7 +380,7 @@ export class Tabs extends Ion {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private _setConfig(attrKey: string, fallback: any) {
|
private _setConfig(attrKey: string, fallback: any) {
|
||||||
var val = this[attrKey];
|
var val = (<any>this)[attrKey];
|
||||||
if (isBlank(val)) {
|
if (isBlank(val)) {
|
||||||
val = this._config.get(attrKey, fallback);
|
val = this._config.get(attrKey, fallback);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user