How to get current URL parameters of a friendly URL?


#1

My app is running on desktop and mobile browsers and mobile apps. I need to get the URL parameters.

For example this URL:

www.mysite.com/user/5456

I need to open my app and get the paramenters ‘user’ and ‘5456’ inside it.

How could I achieve this using Ionic 2?

DeepLink plugins will do this on desktop?


#2
let url = "www.mysite.com/user/5456"
let split_url = url.split('/')
console.log(split_url[1]) // Displays user
console.log(split_url[2]) // Displays 5456

#3

How can I get the URL itself?


#4

You can use window.location.href
http://www.w3schools.com/js/js_window_location.asp