Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70759

Ionic 4 - previous button not working

$
0
0

@viveknarula wrote:

Hi,

I have been using Ionic 4 routing navigation for rotating through previous and next chapters of a book, Its working perfectly fine for Next but on previous button is not loading the content. Below is the code i am using

In HTML -

  <ion-button [routerLink]="['/ch',link.prev]" routerDirection="back" > Previous </ion-button>

<ion-button [routerLink]="['/ch',link.next]"  routerDirection="forward">Next</ion-button>

In .TS file

ngOnInit() {

 this.activatedRoute.params.subscribe((params) => {
       	  if(params.chname)
 	  {
 		this.chname=params.chname;	
 		}
console.log("In activatedRoute",this.chname);
    });  
 
console.log("out activatedRoute",this.chname);
   
 	  if(this.chname)
 	  {
 		this.fetchChNameData(this.chname);	
 		}
 
 
 }

If i tap on NEXT then it works perfectly and i can see the parameter value in this.chname in console.log in both cases “In activatedRoute” and “out acticatedRoute” and fetchChNameData function works to fetch the data.

But when i tap on Back button then i can see this.chname in console.log only in “In activateRoute” but NOT in “Out activatedRoute” resulting fetchChNameData function is not working and not fetching any data.

I don’t know why is it happening.

Can anybody help me please?

Thanks,
Zack

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>