How do I know which states are configured in AngularJS / UI-Router?

Is there a way to see all the states that have been set to $stateProvider ?

In this case, I would like my state assignments to be distributed across many files. I would like to check the built states on run or config in another file.

For example:

 # component1.coffee angular.module('zoo').config ($stateProvider) -> $stateProvider.state 'component1', url: '/component1' template: _template controller: 'Component1Ctrl' # component2.coffee angular.module('zoo').config ($stateProvider) -> $stateProvider.state 'component2', url: '/component2' template: _template controller: 'Component2Ctrl' # componentNavigation.coffee angular.module('zoo').run ($state) -> console.log 'All configured states:', $state.configuredStates # doesn't exist. 

Is there something that will list two states, component1 and component2 ?

+43
angularjs coffeescript angular-ui-router angular-ui
Feb 05 '14 at 23:01
source share
2 answers

$state.get()

returns an array of all states. Enables the top-level abstract state, but you can filter it if you want.

How to list registered states in ui-router?

+88
Feb 06 '14 at 4:14
source share

For those trying to get the actual URL routes, including properly displayed sub-states:

 $state.get().map(function(state) { return $state.href(state.name) }) // => ['/login', '/home', '/something'] 
+6
Apr 27 '17 at 13:12
source share



All Articles