Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用angularjs的主题URL重定向问题_Php_Angularjs_Cookies - Fatal编程技术网

Php 使用angularjs的主题URL重定向问题

Php 使用angularjs的主题URL重定向问题,php,angularjs,cookies,Php,Angularjs,Cookies,我在使用angular js重定向到主题上的特定url时遇到问题。 基本上,在这个主题上,我有一个login.html文件,在验证用户是否在数据库中后,该文件应该重定向到dashboard.html。如果没有,它将保留在登录页面上 我在实现这个功能方面没有问题。但是,我正在尝试实现一个类似会话的功能,在该功能中,它在传输到仪表板时保留登录页面中的变量。目前,我正试图通过ajax调用将变量存储在php$\会话中 登录页面如下所示: <!doctype html> <!-- <

我在使用angular js重定向到主题上的特定url时遇到问题。 基本上,在这个主题上,我有一个login.html文件,在验证用户是否在数据库中后,该文件应该重定向到dashboard.html。如果没有,它将保留在登录页面上

我在实现这个功能方面没有问题。但是,我正在尝试实现一个类似会话的功能,在该功能中,它在传输到仪表板时保留登录页面中的变量。目前,我正试图通过ajax调用将变量存储在php$\会话中

登录页面如下所示:

<!doctype html>
<!-- <html ng-app='login'> -->
<html ng-app="dashboardApp" ng-controller="MainCtrl" class="no-js {{containerClass}}">
<head>
<link rel="stylesheet" href="styles/vendor.00b812ba.css">
<link rel="stylesheet" href="styles/main.02bb4eb8.css">

</head>
<body ng-controller='loginBodyCtrl'>
<form id = 'redirectToDashboard' ng-submit = 'newDataSource()'>
<label>Username</label>
<input id = 'name' type = 'text' ng-model='formData.name'></input>
<label>Password</label>
<input id = 'password' type = 'password' ng-model='formData.password'></input>
<!-- <input type = 'Submit'> -->
<input type = 'Submit'>
</form>

<form id = 'forgotPassword'>
<label>Forgot your password? Click here!</label>
<input type = 'Submit'>
</form>
</body>
</html>

<script src="scripts/vendor.297ae76c.js"></script> <!-- Script which contains angularjs -->
<script src="scripts/old_app.11997041.js"></script> <!-- Declares cookies -->
<!-- Custom Script for OLD -->
<script src="scripts/old_custom_script.js"></script>
包含仪表板控制器的文件old_app.js中有一段特别的代码,这给我带来了一些问题:

angular.module('dashboardApp')
.controller('MainCtrl', function ($scope, $http, $location) {

$scope.main = {
title: 'Minovate',
settings: {
navbarHeaderColor: 'scheme-default',
sidebarColor: 'scheme-default',
brandingColor: 'scheme-default',
activeColor: 'default-scheme-color',
headerFixed: true,
asideFixed: true,
rightbarShow: false
}
};

$scope.ajaxFaker = function(){
$scope.data=[];
var url = 'http://www.filltext.com/?rows=10&fname={firstName}&lname={lastName}&delay=5&callback=JSON_CALLBACK';

$http.jsonp(url).success(function(data){
$scope.data=data;
console.log('cecky');
angular.element('.tile.refreshing').removeClass('refreshing');
});
};

$http({
method  : 'GET',
url     : './ajax/checkAuthentication.php',
headers : { 'Content-Type': 'application/x-www-form-urlencoded' }  
// set the headers so angular passing info as form data (not request payload)
})
.success(function(data) 
{
console.log(data);
if(data == 0)
{
// $cookies.put('authCookie', 'declined');
// console.log('Credentials incorrect.');
window.location.replace("./login.html");
}
else if(data == 1)
{
/** if username and password is correct - goes to dashboard **/
// $cookies.put('authCookie', 'approved');
console.log('Dashboard successfully accessed.'); 
}
else
{
window.location.replace("./login.html");
}
});
});
请注意这一行

 window.location.replace("./login.html") 
每次执行此操作时,url都会重定向到

url.../login.html/#/dashboard/app 
但随后浏览器崩溃了


我不知道是什么导致了这个问题,因为在旧的_custom_script.js中有一行类似的代码工作得非常完美。有人能帮忙吗?

我发现的另一个观察结果是,在重定向过程中,它会在字符串末尾添加哈希。例如,…/login.html变成了…/login.html///dashboard/app。如果我能在它重定向后删除这个散列,也许这能帮助我解决问题。
url.../login.html/#/dashboard/app