-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
- v4.x
- v5.x
- v6.x
Current Behavior
The rootParams parameter for ion-nav can be used to pass parameters to the root page (which has been defined using the root attribute). When the root attribute is removed from the ion-nav tag and an ion-router element is used to determine the root page based on the URL, the rootParams parameter for ion-nav is ignored.
This fiddle is an example of the use of rootParams when the root page is specified using the ion-nav root attribute.
This fiddle is an example of how the rootParams parameter cannot be read when an ion-router element is used to determine the root page.
Expected Behavior
The first page should have the contents a: 1, b: 2
Steps to Reproduce
Use the following HTML body:
<body>
<ion-router>
<ion-route url='/' component='new-page'></ion-route>
</ion-router>
<ion-nav></ion-nav>
</body>WIth the following JavaScript:
const nav = document.querySelector('ion-nav');
class NewPage extends HTMLElement {
async connectedCallback() {
this.innerHTML = `
<ion-header class='gallery-page' translucent>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button />
</ion-buttons>
<ion-title>Root Page</ion-title>
</ion-toolbar>
</ion-header>
<ion-content fullscreen class="ion-padding">
a: ${this.a}, b: ${this.b}
<br />
<ion-button>New Page</ion-button>
</ion-content>
`;
const btn = this.querySelector('ion-button');
btn.addEventListener('click', () => {
nav.push('new-page', { a: this.a + 1, b: this.b + 1});
})
}
}
customElements.define('new-page', NewPage);
nav.rootParams = { a: 1, b: 2 };The root page (or first page that is displayed) will have the contents a: undefined, b: undefined, which indicates that rootParams was either unused or overwritten.
Code Reproduction URL
No response
Ionic Info
No response
Additional Information
No response