Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.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 “后退”按钮仅更新url,而不是作为自定义元素导出的角度应用程序中的页面_Angular_Back Button_Angular Router_Html5 History_Popstate - Fatal编程技术网

Angular “后退”按钮仅更新url,而不是作为自定义元素导出的角度应用程序中的页面

Angular “后退”按钮仅更新url,而不是作为自定义元素导出的角度应用程序中的页面,angular,back-button,angular-router,html5-history,popstate,Angular,Back Button,Angular Router,Html5 History,Popstate,上下文:我构建了英雄之旅应用程序,并将其导出为名为app element的自定义元素。我在本地服务器上部署了它 index.html <head> <title>Custom Element Example</title> <base href="/"> <script type="text/javascript" src="bundled.js"></script> </head> &l

上下文:我构建了英雄之旅应用程序,并将其导出为名为app element的自定义元素。我在本地服务器上部署了它

index.html

<head>
    <title>Custom Element Example</title>
    <base href="/">
    <script type="text/javascript" src="bundled.js"></script>
</head>
<body>  
    <app-element></app-element>  
</body>
这造成了一个新问题。它不允许我们现在按下浏览器的前进按钮,因为当我们使用router.navigate方法导航到URL时,URL将成为浏览器历史记录的新顶部

是否有任何方法可以在按下后退按钮的同时呈现页面,并且仍然可以继续

注意:当我直接部署应用程序而不将其导出为自定义元素时,上述问题都不会发生

constructor(private router:Router, private location:PlatformLocation){
    location.onPopState((e)=>{
      console.log(location.href);
      this.router.navigate([/** fetch route from location.href */]);
    })
  };