Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.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
Angular routing 使用“history.replace”替换为角度1.x_Angular Routing_Html5 History_Angularjs Ng Route_Angularjs - Fatal编程技术网

Angular routing 使用“history.replace”替换为角度1.x

Angular routing 使用“history.replace”替换为角度1.x,angular-routing,html5-history,angularjs-ng-route,angularjs,Angular Routing,Html5 History,Angularjs Ng Route,Angularjs,我需要在Angular 1.x应用程序上使用history.replaceState的帮助 我的Chrome扩展与其他人的应用程序交互,我想在该应用程序中加载一个Url,其中包含我的扩展程序可以读取的额外查询参数,然后使用history.replaceState从Url中删除 步骤1:打开www.otherapp.com?extensionToken=MhtkWGUyS#/settings 步骤2:读取xtensionToken=MhtkWGUyS 步骤3:将令牌替换/删除为replaceSt

我需要在Angular 1.x应用程序上使用
history.replaceState
的帮助

我的Chrome扩展与其他人的应用程序交互,我想在该应用程序中加载一个Url,其中包含我的扩展程序可以读取的额外查询参数,然后使用
history.replaceState
从Url中删除

  • 步骤1:打开
    www.otherapp.com?extensionToken=MhtkWGUyS#/settings
  • 步骤2:读取
    xtensionToken=MhtkWGUyS
  • 步骤3:将令牌替换/删除为
    replaceState
    www.otherapp.com#/settings
问题是Angular 1.x不喜欢单独使用history.replaceState:

Angular似乎会将我的更新还原回原始Url,或者完全扰乱Url。是否有人有使用Angular应用程序的
history.replaceState
的经验

我想到的一个解决方案是使用Angular的
$location
来更改状态,但我不知道如何访问Angular范围之外的
$location
。有人知道我怎样才能得到它吗

生成对
$location
的引用的棘手部分是,我的代码将与许多不同的应用程序一起运行,它们有自己独特的
ng-
元素,我不知道这些元素在页面上是什么。我可以假设大多数应用程序在
window.Angular
中都有Angular元素,但我不能简单地假设每个页面的Angular应用程序元素是什么