Angular 4:将对象传递给Routes而不更新Query Params

Sha*_*zmi 12 angular2-routing angular

我正在使用Angular 4,我想将一些对象传递给路由器但不更新查询参数.

user.component.ts

this.router.navigate(["/profile",{
   action: 'edit',
   user: {id: 1, name: 'test', email: 'test@mail.com'}
}]);
Run Code Online (Sandbox Code Playgroud)

APP-routing.module.ts

{ path: 'profile', component: UserProfileComponent }
Run Code Online (Sandbox Code Playgroud)

用户profile.component.ts

this.route.params.subscribe(params => {

});
Run Code Online (Sandbox Code Playgroud)

有帮助吗?

Deb*_*ahK 8

以下是如何使用服务共享数据的示例:http://blogs.msmvps.com/deborahk/build-a-simple-angular-service-to-share-data/

  • 谢谢!我喜欢你的PluralSight Angular课程 (4认同)