$ locationChangeStart,$ routeChangeStart和$ stateChangeStart的区别 [英] Difference between $locationChangeStart, $routeChangeStart, and $stateChangeStart

查看:382
本文介绍了$ locationChangeStart,$ routeChangeStart和$ stateChangeStart的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道什么是这三个不同,其相应的$ locationChangeSuccess,$ routeChangeSuccess和$ stateChangeSuccess。

I wonder what's the difference with these three, with their corresponding $locationChangeSuccess, $routeChangeSuccess, and $stateChangeSuccess.

推荐答案

$ locationChangeStart:
这里使用了$位置提供并且每当网址变更广播。定位更多地是指一个特定的URL的路径。它更像是普通的JavaScript,你可以改变应用程序中的任何路径,如果它在你的应用程序的路由或状态定义并不重要。

$locationChangeStart: this uses the $location provider and broadcasts whenever the URL changes. Location refers more to a Path of a specific URL. It's more like plain javascript, you can change to any path in your application and it doesn't matter if it's defined on your app as route or state.

$ routeChangeStart:
这里使用了$路线供应商,这是一样的,当广播路由变化(与ngRoute使用默认的角度路由器)。这是干什么用的控制器和视图之间的联系。

$routeChangeStart: this uses the $route provider, and it's the same, it broadcasts when the route changes (default Angular router used with ngRoute). This is used to do a link between controllers and views.

$ stateChangeStart:
它发生的状态变化时,和过渡开始时这个广播。它是由UI路由器它提供了一个不同的(更高级的)的实施routeprovider的使用。国家允许你映射和访问有关不同状态​​不同​​的信息,并可以很容易地通过$ stateParams通过国家之间的信息。

$stateChangeStart: it happens when your state changes, and this broadcasts when a transition begins. It is used by ui-router which provides a different (more advanced) implementation of routeprovider. States allow you to map and access different information about different states and you can easily pass information between states via $stateParams.

他们是很相似的,事实上,它们有着相同的名字,但主要区别取决于应用程序使用的路由。如果你正在使用的角度路由器然后坚持的路线,但是,如果你正在使用的用户界面的路由器,坚持状态。这是我可以给你实用的建议。

They are quite similar, in fact they share the same names, but the main differences depends on the routing your application uses. If you are using angular router then stick to routes, however, if you are using ui-router, stick to states. This is practical advice I can give you.

这篇关于$ locationChangeStart,$ routeChangeStart和$ stateChangeStart的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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