Redirect to new Page in AngularJS using $location

前端 未结 6 1382
庸人自扰
庸人自扰 2020-12-01 01:46

I am testing with the following AngularJS $location. I don\'t what\'s the problem with this. Just want to check if the redirection is working or not:

HTML

6条回答
  •  感情败类
    2020-12-01 02:34

    $location won't help you with external URLs, use the $window service instead:

    $window.location.href = 'http://www.google.com';
    

    Note that you could use the window object, but it is bad practice since $window is easily mockable whereas window is not.

提交回复
热议问题