D
D
DTX2016-04-24 00:14:31
JavaScript
DTX, 2016-04-24 00:14:31

Angular2. How to pass a parameter to a component (@Input) in a router?

@RouteConfig([
  {
    path: '/newpost',
    name: 'NewPost',
    component: Comp
  }
])

The Comp component has an @Input Par parameter. How to pass it through the route?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bromzh, 2016-04-24
@DirecTwiX

No way. You can pass data in the route config in the data field , and get this data from the component, for example, in the OnActivate life cycle method , or simply inject the RouteData dependency and get the data in the constructor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question