0

I am using Angular Beta.15, routerOnActivate ran but, previous instruction = null

export class IdvComponent implements OnActivate {
    routerOnActivate(
        curr: ComponentInstruction, prev: ComponentInstruction
    ) {
        console.log(arguments); // <- prev = null
    }
}

I tried to access this component from another component but not accessing it directly

tom10271
  • 4,222
  • 5
  • 33
  • 62
  • That's a quite old version. It's strongly advised to update to the newest router V3-beta.2. – Günter Zöchbauer Jul 28 '16 at 10:11
  • I am upgrading my application to Angular 2 RC.4, facing loads of problems. `OnActivate` and `OnDeactivate` have both removed? What is the substitution? – tom10271 Jul 29 '16 at 04:11
  • Yes, lots of changes. This is why it's good to not waste more time with the old and deprecated router. https://angular.io/docs/ts/latest/guide/router.html#!#guards – Günter Zöchbauer Jul 29 '16 at 04:12
  • For OnActivate, I want to check whether current page(it is a gallery) has previous route or not, if yes when user click close button it will load last page, otherwise, it points to a default page. For OnDeactivate, I need some time to animation a overlay before transiting to next route. So I can only do both in CanActivate and CanDeactivate? Or I should use other hooks? – tom10271 Jul 29 '16 at 04:15
  • There is some animation support for route transitions on its way. I don't understand what you mean by "has previous route" – Günter Zöchbauer Jul 29 '16 at 04:17
  • If user access url: `/collections/slug-1` directly, it don't have previous route as user directly accessing it. If user access this page from `/profile/name-1` to `/collections/slug-1`, then `location.back()` will point back to `/profile/name-1` from `/collections/slug-1`. – tom10271 Jul 29 '16 at 04:20
  • I haven't found anything that allows you to get the previous route. You could subscribe to router events and update the previous in a shared service http://stackoverflow.com/a/35912966/217408 – Günter Zöchbauer Jul 29 '16 at 04:25

0 Answers0