Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 1 | import {IXosState} from '../../../index'; |
| 2 | export interface IRuntimeStatesService { |
Matteo Scandolo | e0d71ea | 2016-12-19 11:56:12 -0800 | [diff] [blame] | 3 | addState(name: string, state: ng.ui.IState): void; |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 4 | } |
| 5 | |
Matteo Scandolo | e0d71ea | 2016-12-19 11:56:12 -0800 | [diff] [blame] | 6 | export function RuntimeStates($stateProvider: ng.ui.IStateProvider): ng.IServiceProvider { |
| 7 | this.$get = function($state: ng.ui.IStateService) { |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 8 | return { |
| 9 | addState: function(name: string, state: IXosState) { |
Matteo Scandolo | 0e36377 | 2017-01-13 11:41:29 -0800 | [diff] [blame] | 10 | // prevent to add multiple time the same state |
| 11 | if (!$state.get(name)) { |
| 12 | $stateProvider.state(name, state); |
| 13 | } |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 14 | } |
| 15 | }; |
| 16 | }; |
| 17 | return this; |
| 18 | } |