Matteo Scandolo | 1aee198 | 2017-02-17 08:33:23 -0800 | [diff] [blame] | 1 | export interface IXosState extends angular.ui.IState { |
| 2 | data: { |
| 3 | model: string |
| 4 | }; |
| 5 | }; |
| 6 | |
| 7 | export interface IXosRuntimeStatesService { |
Matteo Scandolo | e0d71ea | 2016-12-19 11:56:12 -0800 | [diff] [blame] | 8 | addState(name: string, state: ng.ui.IState): void; |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 9 | } |
| 10 | |
Matteo Scandolo | 1aee198 | 2017-02-17 08:33:23 -0800 | [diff] [blame] | 11 | export function XosRuntimeStates($stateProvider: ng.ui.IStateProvider): ng.IServiceProvider { |
Matteo Scandolo | e0d71ea | 2016-12-19 11:56:12 -0800 | [diff] [blame] | 12 | this.$get = function($state: ng.ui.IStateService) { |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 13 | return { |
| 14 | addState: function(name: string, state: IXosState) { |
Matteo Scandolo | 0e36377 | 2017-01-13 11:41:29 -0800 | [diff] [blame] | 15 | // prevent to add multiple time the same state |
| 16 | if (!$state.get(name)) { |
| 17 | $stateProvider.state(name, state); |
| 18 | } |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 19 | } |
| 20 | }; |
| 21 | }; |
| 22 | return this; |
| 23 | } |