见UI路由器配置了什么状态 [英] See what states are configured in ui-router

查看:99
本文介绍了见UI路由器配置了什么状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法看到所有已设置的 $ 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.

<一个href=\"http://stackoverflow.com/questions/21324303/how-to-enumerate-registered-states-in-ui-router\">How枚举注册国UI路由器?

这篇关于见UI路由器配置了什么状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆