Hi there.
I'm new to Angular2 so please bear with me and feel free to correct any 
misconceptions.

Lately I've been looking into routes and child components, and I'm facing 
some issues. Here's the basic routing setup in the main component:
@RouteConfig({
  {path: '/environments/...', component: EnvironmentsView, as: 
'Environments'},
  {path: '/applications/...', component: ApplicationsView, as: 
'Applications'}
})
Used in the template:
...
<a [router-link]="['/Environments']">Environments</a>
<a [router-link]="['/Applications']">Applications</a>
...

This code fails with the error message «Link "["Environments"]" does not 
resolve to a terminal or async instruction. in [null]».
There seems to be two ways I can fix this:
1. I specify all routing in my main component, but this is not really a 
satisfactory solution as the main component isn't supposed to know anything 
about how the sub-components handle their internal routing.
2. I can make the sub modules load asynchronously with "loader: () => 
Promise.resolve(EnvironmentsView)".

I've gone for the second solution, but this triggers something I suspect 
might be a bug:
If I start the app with no path (i.e. "http://localhost:8080";) and click 
around everything works smoothly, the location is changed correctly and no 
errors appear. However, if I try to go directly to a location that should 
show a sub-component (i.e. "http://localhost:8080/#/environments";) then 
I'll receive the same error as earlier «Link "["Environments"]" does not 
resolve to a terminal or async instruction. in [null]».

I know Angular2 is still in alpha, but am I doing something fundamentally 
wrong here?


Couple more questions I've been wondering about:
1. Is it currently possible to specify optional parameters in a route? If 
so, how?

2. I'm curious about the real gain of naming routes and using these names 
instead of the path. That is, I've named my routes "Environments" and 
"Applications", and I reference these routes with "/Environments" and 
"/Applications". I do see that if I ever decide to change the path then 
I'll only have to change the route config. Then again, if I change the path 
I'm very likely to change the route name as well. I find the code much 
easier to read/understand if the router-link value tells me where it'll 
take me, rather than reference the name of the route. Why is it a bad idea 
to/can't we have a route config like «@RouteConfig({ {path: 
'/environments/...', component: EnvironmentsView} })» and router links like 
«[router-link]="['/environments']"»? It's nice to have the possibility to 
reference routes using an alias, but does it have to be mandatory?


Regards,
Vidar Wahlberg

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to