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

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to