[英]Retrieve the data from one component to another
We are trying to use the NavigationExtras to pass data from one component to another (one page to another) like below 我们正在尝试使用NavigationExtras将数据从一个组件传递到另一个组件(从一页传递到另一个),如下所示
viewProjectDetails(e) {
const navigationExtras: NavigationExtras = {
state: {
ProjectInfo: e.data,
UserSelection: this.UserSelection
}
};
this.router.navigate(['dashboard/ProjectShipment'], navigationExtras);
}
I am trying to get the ProjectInfo
and UserSelection
array in to the another component 我正在尝试将
ProjectInfo
和UserSelection
数组放入另一个组件中
projDetail : any;
userSelection: any;
getPrjDetails() {
const navigation = this.activatedRoute.getCurrentNavigation();
const state = navigation.extras.state as {
}
Listen to the queryParams and catch the NavigationExtras 听queryParams并捕获NavigationExtras
this.route.queryParams.subscribe(params => {
console.log(params["state"]);
});
constructor(private router: Router) {
console.log(this.router.getCurrentNavigation().extras.state.Projectinfo);
// should log e.data
}
您需要在构造函数内部调用getCurrentNavigation()
方法,否则导航已完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.