How to pass data to pages and get data

#1

Ionic V3 use
pass;

this.navCtrl.push(SearchPage, { data: this.pageName });

get;

this.page = navParams.get('data');

but V4 can’t access push and navParams. How to do it? Please help

#2

Modals and popovers can. More generally: use a provider. Group pages by functionality, the foo function, and build a FooDataProvider, which is the central brain for all things foo, and the foo pages ask it for information as needed.

2 Likes
#3

app.routing.module.ts

const routes: Routes = [
  { path: '', loadChildren: './tabs/tabs.module#TabsPageModule' },
  { path: 'pageName/:variable1/:variable2', loadChildren: './pages/path/pageName.module#PageNamePageModule' },
];

page.ts

this.navCtrl.goForward('path/' + this.variable1 + '/' +  this.variable2);

then

import { ActivatedRoute } from '@angular/router';

constructor(public navCtrl: NavController, private route: ActivatedRoute,){
    this.getData();
}

getData(){
    this.selected_pipeline = this.route.snapshot.paramMap.get('variable1');
    this.selected_stage = this.route.snapshot.paramMap.get('variable2');
}