$routeParams not available during controller initialization
angularjs, controller, routes
Solution
Basically `$routeParams` isn't available until the route service has changed the route, meaning you should only inject the service in controllers associated with a specific route (the `controller` property for the route).
If you in some other controller needs to know current route etc. you should listen to the various events the route service broadcasts, e.g.
$scope.$on('$routeChangeSuccess', function (ev, current, previous) {
// ...
});
Updated fiddle.
Problem
I'm trying to figure out AngularJS and routing. Can someone take a look at this http://jsfiddle.net/spoon16/p9BBr/ Help me understand why `$routeParams.i` is undefined during initialization. What is the appropriate way to use `$routeParams` in my controllers?