Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative for AngularJS's $route.reload() in Angular2?

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.

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?

like image 571
user3221325 Avatar asked Feb 20 '26 00:02

user3221325


1 Answers

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.

This works for me as of alpha 42.

like image 82
user3221325 Avatar answered Feb 21 '26 13:02

user3221325



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!