gpt4 book ai didi

javascript - 重定向到另一个网页

转载 作者:行者123 更新时间:2023-11-30 16:37:24 25 4
gpt4 key购买 nike

我正在尝试使用 $location.path('/Views/Home.html'); 在按钮单击时将网页重定向到另一个 .HTML 页面,但它没有发生。 URL 正在更改为浏览器,但页面没有重定向。这是我的 AngularJS 代码。

app.controller('LoginformController', function ($scope,$location) {

$scope.LoginCheck = function () {

alert("Trying to login !");

$location.path('/Views/Home.html');

}

scope.PasswordRecovery = function () {
alert("Clicked 2");
}
});

我得到了两个警报功能,但没有得到页面重定向。请帮助..

最佳答案

如果你正在使用 AngularJS 那么你上面的方法是错误的,你需要按照以下方式进行,

首先为“家”创建一条路线

myApp.config(['$routeProvider', function($routeProvider) {

$routeProvider.when('/home', {
templateUrl: 'your respective path/view/home.html',
controller: 'homeCtrl'
});

}]);

然后使用 $location.path 如下,

$location.path("/home");

关于javascript - 重定向到另一个网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32519837/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com