如何查看 AngularJS/UI

编程入门 行业动态 更新时间:2024-10-28 14:33:46
本文介绍了如何查看 AngularJS/UI-Router 中配置了哪些状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

有没有办法查看 $stateProvider 上设置的所有状态?

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

在这种情况下,我希望我的状态分配分布在多个文件中.我想在不同的文件中检查 runconfig 上的构建状态.

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.

有什么东西可以列出两个状态,component1component2?

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.

如何在 ui-router 中枚举注册状态?

这篇关于如何查看 AngularJS/UI-Router 中配置了哪些状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-21 04:52:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/996219.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:AngularJS   UI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!