延迟导航到下一页
问题描述:
我的 angular 站点运行良好,但是当您单击
进入一个项目时,它会立即加载页面,有时在从图像中提取图像时会出现 flash
API、id
类似于 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);
})
}