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