I am trying to implement basic routing using Angular2, but without success: -D Actually, I don’t even have an error, I just get nothing on the page (which does not help me debug the problem ^ ^). Here is what I did:
- Bootstrap "ROUTER_PROVIDERS" from 'angular / router'
- Define routes in the main component (see below).
- Add a router-out element in the template of the main component.
- The main component implements "ngOnInit" and uses a router to redirect the user to a route called "Company".
Routes:
@RouteConfig([ { path: '/company', component: CompanyComponent, name: 'Company' }, { path: '/missions', component: MissionComponent, name: 'Mission' } ])
When I access my page, I am correctly redirected to "/ company", so it looks right, but still I can’t see anything. I tried adding the company element to the template of the main component to find out if this component was in order, and when I do this, it displays correctly, so I don't think the problem is with the component.
I checked out a live example from the angular tutorial, and the only difference I see is that they use the Routes decorator instead of RouteConfig. When I do this, WebStorm only detected “Routes” in “angular2 / alt_router”, and it still doesn't work (I have an error: angular does not find my routes) ...
It seems that if the “router socket” is not found / filled, but I have no idea why.
I am using Angular2 beta 17
angular routing
ssougnez
source share