当路由在AngularJS改变(动画,装载机等)火灾回调 [英] Fire a callback when route is changed (animations, loaders etc) in AngularJS

查看:121
本文介绍了当路由在AngularJS改变(动画,装载机等)火灾回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是相当新的AngularJS。

当路由改变时,NG-查看更改的内容。
我希望能够做的,就是要勾上的一些行为,当路由变化。


  1. 我想能够例如动画我们的观点
    离开(淡出,并且滑动到左侧),当一个视图
    是现成的,褪色和幻灯片视图。
    这可以通过添加类体路线装载,并消除路线变化的类实现全成

  1. I would like to be able to for example animate the view we're leaving (fading out, and sliding to the left) and when the next view is readily available, fade and slide the view in. This could be implemented by adding a class to body on route loading, and removing a class on route change successfull

我想有右侧堆放在发表意见的能力
当前视图,以便当一个向前移动,下一个视图是
第一次加载到当前的右侧,则视口滑向右所以目前看来几乎滑出出
视图,下一个滑入视图(Windows Phone的喜欢关闭帆布导航)

I would like the ability to have the views stacked on to the right of the current view, so that when one moves forward, the next view is first loaded to the right of the current one, then the viewport slides to the right so the current view slides almost out of view, and the next one slides into view (windows phone like off canvas navigation)

时的$ routeProvider正确的地方要做到这一点?

Is the $routeProvider the right place to do this?

是否有任何大师在那里,可以点我在正确的方向?

Are there any gurus out there that could point me in the right direction?

推荐答案

一些调查研究后,有发射用于此目的的事件。

After some more research, there are events fired for this purpose.

$scope.$on('$routeChangeStart', function(scope, next, current){
   //...
});

$scope.$on('$routeChangeSuccess', function(scope, next, current){
   //...
});

如果那些问题是动画的东西(例如在路由变化)我建议使用ngAnimate。
了解更多关于它这里

If ones problem is to animate something (for example on route change) I recommend using ngAnimate. Read more about it here

这篇关于当路由在AngularJS改变(动画,装载机等)火灾回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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