Ok. I found a soloution. I think it is not perfekt but it works.
First define an array
private urlParameters: Array<any> = [];
Then in IonViewDidLoad
if (document.URL.indexOf("?") > 0) {
let splitURL = document.URL.split("?");
let splitParams = splitURL[1].split("&");
let i: any;
for (i in splitParams){
let singleURLParam = splitParams[i].split('=');
if (singleURLParam[0] == "category"){
this.category = singleURLParam[1];
}
if (singleURLParam[0] == "id"){
this.id = singleURLParam[1];
}
let urlParameter = {
'name': singleURLParam[0],
'value': singleURLParam[1]
};
this.urlParameters.push(urlParameter);
}
}
Switch wich page should load
switch (this.category){
case 'music':
this.goToPageMusicURL();
this.showToastWithCloseButton();
break;
case 'events':
this.goToPageEventsURL();
this.showToastWithCloseButton();
break;
}
Go to the page
goToPageMusicURL() {
//push another page onto the history stack
//causing the nav controller to animate the new page in
this.navCtrl.push(MusicPage, this.urlParameters);
this.menuCtrl.close();
}
// For normal click Events
goToPageMusic() {
//push another page onto the history stack
//causing the nav controller to animate the new page in
this.navCtrl.push(MusicPage);
this.menuCtrl.close();
}
This is the code to extract the parameters from the url
if (document.URL.indexOf("?") > 0) {
let splitURL = document.URL.split("?");
let splitParams = splitURL[1].split("&");
let i: any;
for (i in splitParams){
let singleURLParam = splitParams[i].split('=');
if (singleURLParam[0] == "category"){
this.category = singleURLParam[1];
}
if (singleURLParam[0] == "id"){
this.id = singleURLParam[1];
}
let urlParameter = {
'name': singleURLParam[0],
'value': singleURLParam[1]
};
this.urlParameters.push(urlParameter);
}
}