Redirect to new Page in AngularJS using $location

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

    It might help you!

    AngularJs Code-sample

    var app = angular.module('urlApp', []);
    app.controller('urlCtrl', function ($scope, $log, $window) {
        $scope.ClickMeToRedirect = function () {
            var url = "http://" + $window.location.host + "/Account/Login";
            $log.log(url);
            $window.location.href = url;
        };
    });
    

    HTML Code-sample

    Redirect to Click Me!

提交回复
热议问题