路由配置
const routes: Routes = [
{
path: 'share', component: ShareComponent, canActivateChild: [AuthGuard],
children: [
{ path: '', redirectTo: 'sharelist' },
{ path: 'sharelist', component: ShareListComponent, canDeactivate: [CanDeactivateGuard] },
{ path: 'sharedetails/:l', component: ShareDetailsComponent, canDeactivate: [CanDeactivateGuard] }
]
}
];
跳转前页面
import { Router} from '@angular/router';
constructor(private router: Router) {}
seeDetails(l: any) {
this.router.navigate(['/share/sharedetails', JSON.stringify(l)]);
}
跳转后页面
import {ActivatedRoute} from '@angular/router';
constructor(private activeRoute: ActivatedRoute) {
this.activeRoute.params.subscribe((params: Params) => {
this.inte = JSON.parse(params['l']);
});
// this.inte = this.activeRoute.snapshot.params["l"];
}
网友评论