Closed jeme closed 10 years ago
Added overload to allow for:
$state.state(['$register', '$http', function(reg) {
return $http.get().success(function(data) {
reg('statename', { /* use data to configure */ });
});
}]);
where $register
is equivalent to the old $state.state
.
The function that can be provided to state is inject-able and can therefor take e.g. $http
to load states from the server.
Note that in such cases, it should return a promise that resolves when the registration is done.
The registrations can be rerun using $state.reinitialize()
.
Gives an alternative way to define states that can get reinitialized during runtime. Mainly to give the possibly for the server to define the configuration.
Reinitialization should integrate with websockets or a wrapper API that provides some fallback mechanism that does long polling or something, this is to let the client automatically detect if the server changes the route configuration.