javascript AngularJs ui-router $location 还是 $state?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26138140/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 05:33:35 来源:igfitidea点击:
AngularJs ui-router $location or $state?
提问by itsme
How can I transform this:
我怎样才能改变这个:
$location.path('/app/home/' + id).search({x:y});
to this:
对此:
$state.go('/app/home/' + id).search({x:y});
I tried, but I actually can't get enough information how to achieve that...
我试过了,但实际上我无法获得足够的信息来实现这一目标......
回答by Radim K?hler
There is nice documentation (while deprecated, still really clear):
有很好的文档(虽然已弃用,但仍然很清楚):
$state.go(to [, toParams] [, options])
$state.go(to [, toParams] [, options])
Let's say that the state
definitions are looking like this:
假设state
定义如下所示:
.state('app', { // parent app
url: '/app',
...
})
.state('app.home', {
url: '/home/:x', // the param named x
...
Then you will do
然后你会做
$state.go('app.home', {x:y});
This Q&A could help as well:
此问答也可以提供帮助: