I have a heroku app that is built on node.js and ionic/angular. The site url looks like
myapp.herokuapp.com
Because it is ionic/angular and relies on states and views when you type in the url it brings you to the home page
myapp.herokuapp.com/www/index.html#/login
which is fine.
The problem is that I want to create personalized referrer links for 3rd parties to send people to my app. In theory that would look like this
myapp.herokuapp.com?ref=12345
The 'ref' parameter is useful to me and I want to extract it when my first controller loads and bind it to a variable in a service. Because of the states and views, though, the url ends up being
myapp.herokuapp.com/www/index.html?ref=12345#/login
by the time I get to my first controller at the 'login' page.
The site still works like this but I can't help but feel like I am doing it wrong. There must be an angular way to extract a GET parameter from the url without some crazy string analysis and concatenation when my first controller loads.
If you use routeProvider, you can do something like this:
$routeProvider
.when('/Index', { templateUrl: baseUrl + "/Index" })
.when('/Index/:parameter1/:parameter2/', {
templateUrl: function (params) {
return baseUrl + "/Index/GetSomething?idparameter1=" + params.parameter1+ "&idparameter2=" + params.parameter2;
}
})
I hope it can help you.