简体   繁体   English

使用AngularJS路由加载页面

[英]Loading page with AngularJS routes

I want to use Angular routes for creating small website for mobile. 我想使用Angular路线创建移动小网站。 Is there any way to add loading icon while loading a partial and swap the entire page to the right when switching? 是否有任何方法可以在加载部分时添加加载图标并在切换时将整个页面交换到右侧? (like in native mobile app animation (比如原生移动应用动画

But change: 但改变:

  • $beginRouteChange to $routeChangeStart $ beginRouteChange到$ routeChangeStart
  • $endRouteChange to $routeChangeSuccess $ endRouteChange到$ routeChangeSuccess

and things will work. 事情会奏效。

Check out Misko's answer about delaying route changing. 查看Misko关于延迟路线变更的答案 He links to an example, too which is helpful. 他也链接到一个例子,这也很有帮助。 Basically, you have to add to your routing logic a resolve function which will allow you to prevent showing of the new route until asynchronous calls are resolved, and observing the $beginRouteChange and $endRouteChange on the $rootScope ( example code here ) 基本上,您必须在路由逻辑中添加一个resolve函数,它允许您在异步调用解析之前阻止显示新路由,并在$rootScope上观察$beginRouteChange$endRouteChange此处 $rootScope 示例代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM