Angular 在角度布线中从堆栈中删除以前的页面
我是angular的新手,我想尝试在其上构建我的应用程序。我只有一个普通的两页应用程序。我可以看到路由行为正常,但我可以看到当我从键盘按back键时,我返回到登录页面Angular 在角度布线中从堆栈中删除以前的页面,angular,Angular,我是angular的新手,我想尝试在其上构建我的应用程序。我只有一个普通的两页应用程序。我可以看到路由行为正常,但我可以看到当我从键盘按back键时,我返回到登录页面 登录->主页,按后退按钮主页->登录 现在我希望登录页面从堆栈中删除,所以当我们点击键盘背面时,它什么也不做。类似于每次访问上一页时从堆栈中删除上一页。我不希望我的用户在不注销的情况下返回到登录页面 主页: //going to the home page with this click on the button <bu
登录->主页
,按后退按钮主页->登录
现在我希望登录页面从堆栈中删除,所以当我们点击键盘背面时,它什么也不做。类似于每次访问上一页时从堆栈中删除上一页。我不希望我的用户在不注销的情况下返回到登录页面
主页:
//going to the home page with this click on the button
<button type="submit" class="btn btn-primary" (click)="submit()">Submit</button>
submit(){
(<any> window).location = '/home';
}
<div class="logout-link col-4">
<a routerLink="/">Logout</a>
</div>
到目前为止,我尝试的是这样做:
//homepage logout button
[routerlink] = "['/', {clearhistory: true}]" //This disabled the route functioning at all, I could not go to home by tapping on the logout button.
//loginpage submit button
submit(){
this.route.navigate(['/home'], {clearhistory: true}) //did nothing I can again come back with the keyboard back
}
有没有办法达到我想达到的目标。谢谢您正在寻找的选项是。这将替换历史记录中的状态,您将无法返回到以前的URL 或者,您也可以使用导航,而无需将状态推入历史
this.route.navigate(['/home'], { replaceUrl: true });
谢谢,我只是在寻找答案。还有一个问题是,有没有办法在
routerLink
中的HTML文件中添加相同的内容,因为我这样做时会出错:
据我所知,导航附加功能只能在以编程方式导航时使用,而不能在模板级别使用。这样地