I want to redirect to another web page when I click a button. Please find the following code
js
app.controller('myCtrl', ['$scope', '$location', function($scope, $location) {
$scope.redirect = function()
{
console.log($location.url());
};
}
I can obtain the current url using $location.url() which is follows
http://IP:Port/?myId=this-is-my-test-page
What I want to do is i want to redirect to the following page when i click a button
http://IP:Port/?myId=this-is-my-test-page2
I want to edit the existing url inside the controller without hard coding the whole url as IP and Port can be changed. How can I achieve this?
Although I used $location.path("http://IP:Port/?myId=this-is-my-test-page2");
What is does is it appends to the current url as follows
http://IP:Port/?myId=this-is-my-test-page2#http://IP:Port/?myId=this-is-my-test-page2
How can I redirect to the required page ?