Reputation: 172
I have a button in my Ionic app in page1. Through this button, I'm making a call to a function called myfunc(item.url).
<ion-item (click)="myfunc(item.url)">
<ion-label color="primary"> Click here! </ion-label>
</ion-item>
The function for myfunc(item.url) is something like this:
myfunc(imageUrl:string) {
this.nav.navigateForward('/page2/${imageUrl}');
}
Here I'm passing an url from page1 to page2 something in the format of http://example.com/xyz.
The problem that I'm facing is when I pass an url only http:
is getting stored in the variable. That is I'm unable to get the entire url with forward slashes.
ngOnInit() {
this.receivedUrl = this.activatedRoute.snapshot.paramMap.get('imageUrl');
/* Expected Output: this.receivedUrl = "http://example.com/xyz" but
Obtained Output is: this.receivedUrl = "http:" */
}
Please help me get the entire url instead of just http: . Thank you in advance.
Upvotes: 1
Views: 505
Reputation: 267
Encode Image Url before passing as url have special character due to which you are not able to get the whole image url
this.nav.navigateForward(`/page2/${encodeURI(imageUrl)}`);
Upvotes: 1