Angular2 Nativescript router prevent automatic component reuse


#1

Hi,

I have spent a lot of time with this topic, and I still without answer.

I have a detailed component /noticia/:id but angular 2 routing is reusing the component avoiding the default transition when I change from /noticia/1 to noticia/2 …noticia/3 etc.

Anyone can help me? or someone have other idea to solve this.

Thanks a lot !

My problem can see on the next link: https://drive.google.com/open?id=0B2oa3frtO834MWp2ZUV0TEc4Z28


#2

Hello, Alberto! Here is my code to handle this:

ngOnInit() {
  this.sub = this.route.params.subscribe(params => {
    /*Code*/ 
 })
ngOnDestroy() {
  this.sub.unsubscribe();
})

I haven’t used default transitions here, but used angular animations instead.


#3

Hi @redsool,

I actually do what you suggest, I do not have problems reading and changing the information depending on params my problem is the animation when this information change.

I have tried the routerExtension navigation with animation but like angular lifecycle is reusing the component it is not calling ngDestroy or ngOniti until It is using the same component, I also tried angular animations, but I do not know where to pot the flag to change the state, may be I am doing wrong, do you have any code example?

I really appreciate it thanks !