使用ui路由器AngularJS 1.x获取给定的状态url

Get state given url with ui-router AngularJS 1.x

本文关键字:状态 url 获取 ui 路由器 AngularJS 使用      更新时间:2023-09-26

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

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

注册路线:

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

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

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

注册路线:

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

结果:auth/enterprise/esrubal=>auth.conf

解决方案

您可以使用$stateProvider上的.decorator钩子来公开内部状态实现。你可以装饰州建筑商的任何财产;我武断地选择了"家长"。

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