My app should have a different default route depending on the value set in a cookie. But within my router config $cookies
isn't defined - at this stage in the app's bootstrapping it seems that only $cookieProvider
is defined (and similarly $cookieStore
isn't available either). How do I get from this to the actual $cookies
object that is accessible later by my services.
angular.module('jnr').config(['$routeProvider', '$locationProvider', '$cookiesProvider', function($routeProvider, $locationProvider, $cookiesProvider) {
$locationProvider.html5Mode(true).hashPrefix('!');
$routeProvider.when('/tunes', {
templateUrl: '/views/list-tunes.html'
}).when('/tunes/:instrument', {
templateUrl: '/views/list-tunes.html'
}).otherwise({
redirectTo: '/tunes/' + ([get instrument from the cookie here] || 'clarinet')
});
}]);
};