0

I have the following code

$scope.insertTodo = function(){
                    TodoService.post($scope.todo);
                    $location.path("/#/");
                    }

It should run TodoService.post() (and he does fine) and after that redirect the user to /#/ location. The redirect is not working. What am i doing wrong ?

Thank you.

1 Answer 1

1

You need to change $window.location.href like this

var app = angular.module('RedirectApp', []);
app.controller('RedirectURLCtrl', function($scope, $window) {
  $scope.RedirectToURL = function() {
    var host = $window.location.host;
    $window.location.href = "http://" + host + "/#/";
  };
});
Sign up to request clarification or add additional context in comments.

1 Comment

Works like a charm. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.