微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

angularjs – 查看在ui-router中配置的状态

有没有办法看到已经设置在$ stateProvider的所有状态?

在这种情况下,我希望我的状态分配分布在许多文件。我想检查在运行或配置在不同的文件中构建的状态。

例如:

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

$ state.get()

返回所有状态的数组。包括顶级抽象状态,但你可以过滤掉,如果你想要的。

How to enumerate registered states in ui-router?

原文地址:https://www.jb51.cc/angularjs/145987.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐