无法使用$ state.go从Controller重定向到子状态。
我可以使用ui-sref导航到子状态,但是当我使用控制器执行相同操作时,我总是会转到默认状态,即重定向。
$stateProvider.state('my-profile', {
url: "/my-profile",
redirectTo: 'my-profile.a',
templateUrl: 'template-path'
}).state('my-profile.a', {
url: '/a',
templateUrl: 'template-path'
}).state('my-profile.b', {
url: '/b',
templateUrl: 'template-path'
})
this.$state.go("my-profile","b"); Redirects to a
this.$state.go("my-profile/b"); Redirects to a
this.$state.go("my-profile.b"); Redirects to a
我需要去“ b”路线
答案 0 :(得分:0)
$ state.go获取状态名称作为参数。所以这两个是错误的用法:
this.$state.go("my-profile","b"); Redirects to a
this.$state.go("my-profile/b); Redirects to a
第三个是正确的语法,但是缺少引号。这应该起作用:
this.$state.go("my-profile.b");
在此处查看文档: ui-router documentation