javascript - 使用 ui-router AngularJS 1.x 获取给定 url 的状态

标签 javascript angularjs angular-ui-router

如何将当前URL转换为相应的状态?结果状态将用于使用 $state.go 进行状态转换。

示例: http://localhost/auth/enterprise/

注册路线:

{
"stateName": "auth.context",
"url": ":context"
}

结果:auth/enterprise/=> auth.context

示例: http://localhost/auth/enterprise/esdrubal

注册路线:

{
"stateName": "auth.context",
"url": ":context/:username"
}

结果:auth/enterprise/esdrubal => auth.context

最佳答案

解决方案:

You can expose the internal state implementation by using the .decorator hook on $stateProvider. You can decorate any property of the state builder; I chose 'parent' arbitrarily.

https://stackoverflow.com/a/30926025/5485700

关于javascript - 使用 ui-router AngularJS 1.x 获取给定 url 的状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33521286/

相关文章:

javascript - 如何防止刷新页面后重新加载整个 ng-admin

javascript - 具有动态 URL 的 Angular UI 路由器

javascript - 并排对齐部分

javascript - 动态查找 jquery 元素(如果存在)

javascript - 编写对象的静态数组

javascript - AngularJS ng-repeat 不重新渲染转发器(UI)并且不再次调用 ng-init

html - ionic 背景图像未在设备上显示

javascript - Zendesk 应用程序错误和 Webhook 发布延迟/失败

javascript - 使用ui-router时如何构建 Angular 应用程序

javascript - Controller ---工厂: passing parameters