见UI路由器配置了什么状态路由器、状态、UI

2023-09-14 00:20:48 作者:单人行离人梦

有没有办法看到所有已设置的 $ stateProvider

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

在这种情况下,我想我的状态分配,在许多文件分发。我想在检查在不同的文件中运行配置内置状态。

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

例如:

# 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.

有一些会列出两种状态, COMPONENT1 COMPONENT2

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

推荐答案

$ state.get()

返回所有国家的数组。包括顶级抽象的状态,但是可以筛选出来,如果​​你想要的。

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

How枚举注册国UI路由器?