有没有办法查看所有已设置的状态$stateProvider?
$stateProvider
在这种情况下,我希望状态分配可以分布在许多文件中。我想检查不同文件上run或config文件中的构建状态。
run
config
例如:
# 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?
component1
component2
$state.get()
返回所有状态的数组。包含顶级抽象状态,但是您可以根据需要将其过滤掉。
如果您查看$state.get()最新版本的ui-router 的文档,则会注意到不向函数传递任何参数应返回所有已配置状态对象的数组。
/** * @ngdoc function * @name ui.router.state.$state#get * @methodOf ui.router.state.$state * * @description * Returns the state configuration object for any state by passing the name * as a string. Without any arguments it'll return a array of all configured * state objects. * * @param {string|object} stateOrName The name of the state for which you'd like * to get the original state configuration object for. * @returns {object} State configuration object or array of all objects. */