Hi Roman!
Actually you can illustrate $route behavior with jsFiddle (or even
better - plunker), I was blogging about this few weeks back.
Anyway, this jsfiddle:
http://jsfiddle.net/pkozlowski_opensource/pt39h/1/ shows that you can
have access to $routeParams in both Main and Sub controllers.
The problems you were having in your example is that you were trying
to log things in a controller's constructor function. Those functions
are not run on each and every route change but only when a respective
scope is created / destroyed.
In your example the Main controller was called only once (at the
application's startup), before a route was matched so this is why it
was undefined. The sub-controller, on the other hand, is re-created on
each route match (and after a route is matched) so this is why it was
defined correctly.
Hope that the above explanations make sense but if not please feel
free to play with the attached fiddle and ask more questions.
Cheers,
Pawel
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To post to this group, send email to
ang...@googlegroups.com.
> To unsubscribe from this group, send email to
>
angular+u...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/angular?hl=en.
>
>