我想要将数据传递到另一个页面。我的app-routing.module是这样的:
const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', loadChildren: './home/home.module#HomePageModule' },
{ path: 'web-page/:url', loadChildren: './web-page/web-page.module#WebPagePageModule' },
{ path: 'qrscan', loadChildren: './qrscan/qrscan.module#QrscanPageModule' },
];
使用HTML,我可以成功地传递数据:
<ion-button expand="full" [routerLink]="['/web-page/', urlBooking]" routerDirection="forward">BOOKING</ion-button>
但我很难在typescript中做到:
this.router.navigate(['web-page'], { queryParams: { 'url': "https://apple.stackexchange.com/questions/180387/xcode-failed-to-download-use-the-purchases-page-to-try-again" } });
发布于 2019-04-05 15:36:59
你没有说什么不起作用,但是你可能想要对你的查询参数进行url编码。这应该可以很好地工作。并在使用该参数的地方使用decodeURIComponent
。
const url = encodeURIComponent("https://apple.stackexchange.com/questions/180387/xcode-failed-to-download-use-the-purchases-page-to-try-again");
this.router.navigate(['web-page'], { queryParams: { url } });
https://stackoverflow.com/questions/55517457
复制相似问题