Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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
一旦我访问了AngularJS中的一个位置,我如何获得上一个位置?_Angularjs_Url_Path_Location - Fatal编程技术网

一旦我访问了AngularJS中的一个位置,我如何获得上一个位置?

一旦我访问了AngularJS中的一个位置,我如何获得上一个位置?,angularjs,url,path,location,Angularjs,Url,Path,Location,以下代码段仅在我离开当前位置后有效。我一开始就需要上一个位置。我怎样才能做到这一点 $scope.$on('$locationChangeStart', function(e, currentLocation, previousLocation){ console.log('locationChange'); //alert(previousLocation); }); 您可以使用document.referer并使用以下内容检查URL是否与您的应用程序匹配: docu

以下代码段仅在我离开当前位置后有效。我一开始就需要上一个位置。我怎样才能做到这一点

$scope.$on('$locationChangeStart', function(e, currentLocation, previousLocation){
      console.log('locationChange');
      //alert(previousLocation);
});

您可以使用
document.referer
并使用以下内容检查URL是否与您的应用程序匹配:

document.referrer.indexOf(window.location.hostname) > -1

“从一开始就正确”是什么意思?页面何时加载?是的。加载页面后,我想保存数据库中的上一个位置。所以这个位置不一定是你的应用程序,对吗?我可以从外部网站访问你的应用。如果它是我的应用之一,我将使用它。否则我会忽略它。似乎没有简单的方法可以做到这一点。。。