UI-Router
is different than Angular
's ngRoute
. It supports everything the normal ngRoute
can do as well as many extra functions.
I am changing my Angular
app from ngRoute
to UI-Router
. But I cannot quite figure out how to inject resolve
function programmatically - the piece of code that I use outside Controller
and config
.
So, with standard Angular
's ngRoute
I can dynamically inject my resolve promise
in the Angular
run block:
app.run(function ($route) {
var route = $route.routes['/'];
route.resolve = route.resolve || {};
route.resolve.getData = function(myService){return myService.getSomeData();};
});
Now how do I inject resolve promise in a similar way using UI-Router
? I tried passing $stateProvider
to get access to state
s but that was failing for me.
angular.module('uiRouterSample').run(
[ '$rootScope', '$state', '$stateProvider'
function ($rootScope, $state, $stateProvider) {
//$stateProvider would fail