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

gsc*_*ger 26 angularjs angular-ui-router

我想知道在使用ui-router时是否有办法列出所有注册状态

Mat*_*Way 44

如果您查看$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.
 */
Run Code Online (Sandbox Code Playgroud)