在Angular2中替代AngularJS的$ route.reload()吗? [英] Alternative for AngularJS's $route.reload() in Angular2?

查看:212
本文介绍了在Angular2中替代AngularJS的$ route.reload()吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够通过Angular2应用程序完全重新加载,因为数据有所更改.我可以通过$route.reload()(甚至是$state.go($state.current.name, $state.params, {reload: true}))在AngularJS中做到这一点,但现在找不到等效项.

I would like to be able to fully reload by Angular2 app because something has changed in the data. I could do that in AngularJS through $route.reload() (or even $state.go($state.current.name, $state.params, {reload: true})), but I can't find an equivalent now.

我知道有Router.renavigate(),但这似乎没什么用.它应该按照我的要求做吗?还有另一种方法吗?

I know there's Router.renavigate(), but that doesn't seem to do much. Is it supposed to do what I'm asking for? Is there another way?

推荐答案

我想我已经知道了.如果组件实现CanReuse(来自角度/路由器")并从其覆盖的canReuse()方法返回false,则router.renavigate()将丢弃该组件并对其进行重建.

I think I have figured this out. router.renavigate() will throw away the Component and rebuild it if the Component implements CanReuse (from 'angular/router') and returns false from the canReuse() method it overrides.

从42版开始,这对我有效.

This works for me as of alpha 42.

这篇关于在Angular2中替代AngularJS的$ route.reload()吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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