传值:
导入:
import { NavigationExtras, Router } from '@angular/router';
方法里
const navigationExtras: NavigationExtras = {
queryParams: {name: JSON.stringify(值)},
skipLocationChange: true, //不修改url,值不显示在url里
fragment: 'anchor',
};
this.router.navigate(['/state'], navigationExtras);
接收
导入:
import {ActivatedRoute} from '@angular/router';
this.activatedRoute.queryParams.subscribe((queryParams: any) => {
this.customers = JSON.parse(queryParams.name)
});