I'm using Angularjs 1.4.2 and I need to redirect to another URL after $
http.post success callback. I know I can use something like: $window.location.href = "
http://google.com", but in this case
I think need to call a function in the service from the custom directive to get the URL dynamically.
//custom directive
$scope.login = function () {
var loginResponse = {};
var errorMessage = "";
var access_token = "";
loginService.login(myInfo).then(function(response) {
console.log("response is: " + JSON.stringify(response));
if(response.data.token) {
$window.sessionStorage.setItem("token", response.data.token);
//Do I make the call from here?
$window.location.href = loginService.getURL();
}else{
errorMessage = response.data.errorMessage.split(":").pop();
console.log("errorMessage is: " + errorMessage);
... more code
So, is this a bad practice the way I'm trying to implement it?
Thank you,
James