Ionic-framework: NavController.setPages() with nav params - unclear documentation

Created on 29 Nov 2016  路  4Comments  路  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[ ] 1.x
[X] 2.x

I'm submitting a ... (check one with "x")
[X] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

The documentation lists NavController.setPages() to take an array of pages with their params as the first argument. However, there is no example of doing this and I cannot, for the life of me, figure it out.

Expected behavior:

import {HelloPage} from "pages/hello";
[...]
// works as expected
let options = {name: "Bill"};
this.navController.setRoot(HelloPage, options);


// how would I pass the params in setPages?
this.navController.setPages([GoodbyePage, HelloPage]);
this.navController.setPages([GoodbyePage, HelloPage], options); // doesn't work
this.navController.setPages([GoodbyePage, [HelloPage, options]]); // what I expected to work but doesn't

Most helpful comment

I think I figured it out but only after pouring through the source code. There are no easy examples online, anywhere.

this.navController.setPages([GoodbyePage, {page: HelloPage, params: options}]);

All 4 comments

I think I figured it out but only after pouring through the source code. There are no easy examples online, anywhere.

this.navController.setPages([GoodbyePage, {page: HelloPage, params: options}]);

THX for this save my day

This issue was moved to driftyco/ionic-site#970

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fdnhkj picture fdnhkj  路  3Comments

MrBokeh picture MrBokeh  路  3Comments

gio82 picture gio82  路  3Comments

brandyscarney picture brandyscarney  路  3Comments

brandyscarney picture brandyscarney  路  3Comments