Redirect to new Page in AngularJS using $location

前端 未结 6 1363
庸人自扰
庸人自扰 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:41

    The line

    $location.absUrl() == 'http://www.google.com';
    

    is wrong. First == makes a comparison, and what you are probably trying to do is an assignment, which is with simple = and not double ==.

    And because absUrl() getter only. You can use url(), which can be used as a setter or as a getter if you want.

    reference : http://docs.angularjs.org/api/ng.$location

提交回复
热议问题