THIS PROJECT IS NO LONGER MAINTAINED -- Extras for UI-Router for AngularJS. Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition)
I would like to register dynamic states determined once the user logs in. I find I can register states with the $futureStateProvider at the config() phase but if I try to register the state in my Controller at runtime it is registered but not resolved. I'm keeping a reference to the $futureStateProvider, so I thought I could register the state in the Controller.
This seems to only happen when navigating by Url (http://localhost:3000/home/iframe2). If I navigate with $state.go("iframe2") it works.
Below is a demo where I'm trying to register a simple state.
Any help is appreciated :)
Controller
app.controller("DemoController", function () {
// NOTE - This doesn't work !
var futureState = {
stateName: "iframe2",
url: "/home/iframe2",
type: "dataStoreState",
src: "iframe2.html"
};
app.futureStateProvider.futureState(futureState);
});
Router
app.config(function ($futureStateProvider,$stateProvider, $locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
$stateProvider
.state("app", {
abstract: true,
templateUrl: "/app/layouts/app",
controller: "ApplicationController as vm"
})
.state("app.home", {
url: "/home",
views: {
"content": {
templateUrl: "/app/home/index",
controller: "DemoController as vm"
}
}
});
function dataStoreStateFactory($q, futureState) {
var state = {
name: futureState.stateName,
url: futureState.url,
parent:"app",
views: {
"content": {
templateUrl: "/app/home/demo"
}
}
};
return $q.when(state);
}
app.futureStateProvider = $futureStateProvider;
app.futureStateProvider.stateFactory("dataStoreState", dataStoreStateFactory);
// NOTE: If I register the future state here it works fine
var futureState = {
stateName: "iframe2",
url: "/home/iframe2",
type: "dataStoreState",
src: "iframe2.html"
};
app.futureStateProvider.futureState(futureState);
});
I would like to register dynamic states determined once the user logs in. I find I can register states with the $futureStateProvider at the config() phase but if I try to register the state in my Controller at runtime it is registered but not resolved. I'm keeping a reference to the $futureStateProvider, so I thought I could register the state in the Controller.
This seems to only happen when navigating by Url (http://localhost:3000/home/iframe2). If I navigate with $state.go("iframe2") it works.
Below is a demo where I'm trying to register a simple state.
Any help is appreciated :)
Controller
Router