延迟导航到下一页 [英] Delay navigating to next page

查看:30
本文介绍了延迟导航到下一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 angular 站点运行良好,但是当您单击进入一个项目时,它会立即加载页面,有时在从图像中提取图像时会出现 flashAPIid 类似于 1 秒的延迟或页面过渡效果.

My angular site works great, but when you click into a project it loads the page, right away and sometimes there is a flash while the images are pulled from the API, id like a 1 second delay, or page transition effect.

但我不确定如何在 Angular 2 中实现这一点.有兴趣了解其他人在做什么吗?

but i'm not sure how to implement this in Angular 2. Interested to hear what others are doing ?

提前致谢

推荐答案

你可以实现 CanDeactivate 接口,类似这样:

You can implement CanDeactivate interface, something like this:

routerCanDeactivate(currTree?: RouteTree, futureTree?: RouteTree): Promise <boolean> {
  return new Promise((resolve, reject) => {
    setTimeout(() => resolve(true), 1000);
  })
}

这篇关于延迟导航到下一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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