Trying to set up routes in Angular 2, but not using TypeScript? The documentation isn’t too clear on this right now.
In fact, as of this writing,
But what if you want a
Component decorator too? Try sticking a
.Component in there and it produces an error:
What’s the trick?
Decorators return functions that wrap Components
RouteConfig with your configuration – this returns a function that, when called with a Component, applies that RouteConfig to that Component. Like this:
The other decorators work the same way. In TypeScript you’d use
@Whatever – in ES5 or ES6, call that function as
ng.module.Whatever(), then pass your component to the function it returns.
Learning React can be a struggle -- so many libraries and tools!
My advice? Ignore all of them :)
For a step-by-step approach, read my book Pure React.