AngularJs ui-router $location 还是 $state? [英] AngularJs ui-router $location or $state?

查看:25
本文介绍了AngularJs ui-router $location 还是 $state?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何转换:

$location.path('/app/home/' + id).search({x:y});

到此:

$state.go('/app/home/' + id).search({x:y});

我尝试过,但实际上我无法获得足够的信息来实现...

I tried, but I actually can't get enough information how to achieve that...

推荐答案

有很好的文档(虽然已弃用,但仍然非常清晰):

假设 state 定义如下所示:

Let's say that the state definitions are looking like this:

.state('app', { // parent app
  url: '/app',
  ...
})
.state('app.home', {
  url: '/home/:x',         // the param named x
  ...

然后你会做

$state.go('app.home', {x:y});

这个问答也有帮助:

这篇关于AngularJs ui-router $location 还是 $state?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆