ionic page jump mass participation
Before the jump page
First, the introduction of a package
import {NavController} from '@ionic/angular';
Secondly load dependence in the constructor
constructor(public nav:NavController) {}
Then carry parameters jump page
this.nav.navigateRoot(['news'],{
queryParams:{
'page':"123",
'wjw':"zheshiyigecanshu"
}
});
Ts in the receiving parameter page
Acquisition parameters in the new page, first le, import a small bag
import { ActivatedRoute, Params } from '@angular/router';
Then directly accept parameters in a constructor
constructor(public activeRoute: ActivatedRoute) {
this.activeRoute.queryParams.subscribe((params: Params) => {
this.page = params['page'];
this.page1 = params['wjw'];
console.log("params:",this.page,this.page1)
});
}
OK!
go back to the last page
Add a button to the new page, click the return button, go to previous
back(){
this.nav.back()
}
Ionic update on the speed and pace of development, like China, fast chicken thief child, can not say Shashi Hou has changed,
There is a way, I feel this good
Previous page
Guide package
import { Router } from '@angular/router';
Inject dependencies
constructor( public router: Router) {}
Jump pages
this.router.navigate(['news'], {
queryParams: {
'wjw': 'nihao'
}
});
Second page
Also have the leader packet, and upper as
import { ActivatedRoute, Params } from '@angular/router';
Inject dependencies
constructor(public activeRoute: ActivatedRoute ) {}
Accept parameters
this.activeRoute.queryParams.subscribe((params: Params) => {
console.log(params['wjw']);
});