dotJEM / angular-routing

Enhanced state based routing for Angular applications!
https://dotjem.github.io/angular-routing/
MIT License
75 stars 9 forks source link

Provide ability to bind state configuration to server side and refresh at runtime #19

Closed jeme closed 10 years ago

jeme commented 11 years ago

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.

jeme commented 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().