Angular: no way to pass an object through a router?

前端 未结 5 2047
走了就别回头了
走了就别回头了 2021-01-26 09:17

I\'ve been trying to find a simple solution.

I have a for loop displaying a list of items. clicking on one of the items routes you to the detailed component and I just wa

5条回答
  •  耶瑟儿~
    2021-01-26 09:30

    Objects passing by routing is limited options. Using a service is the better option. If you provide a service instance by the parent component, then the same instance gets injected in parent and child and you have the shared data available immediately.

    https://stackblitz.com/edit/angular-6-communicating-between-components-1gunkw?file=app%2Fapp.component.ts

提交回复
热议问题