重定向并在导航结束时调用另一种方法。角5

发布于 2025-01-27 08:07:48 字数 627 浏览 4 评论 0原文

我有一个登录屏幕,着陆屏幕和模态弹出屏幕。

场景之一是用户成功登录 - >显示着陆页 - >显示模态弹出屏幕。

login.ts:具有重定向的代码并调用其他组件的另一种方法。

@ViewChild(ModalPopup)
public modalPoupup: ModalPopup| undefined;
getBillingPage(){
   let user = this.userService.getUser();
   this.redirect(this.landingPage.toString());
   this.modalPoupup.openMyModal();
   }

ModalPopup.ts:具有显示/隐藏模式的方法,

public openMyModal() { 
   this.myModal.show();
   }

以上代码成功重定向,但未打开模态弹出窗口。

如果我在登录。TS中删除redirect(),并且仅具有openmymodal(),则显示模态,但是当模态关闭时,仍会显示登录页面而不是着陆页。

可以实现这一目标吗?

I have a login screen, a landing screen and a Modal Popup Screen.

One of the scenarios is User successfully Logs In --> Show Landing page --> Show Modal Popup screen.

Login.ts : has the code to Redirect and call another method of a different component.

@ViewChild(ModalPopup)
public modalPoupup: ModalPopup| undefined;
getBillingPage(){
   let user = this.userService.getUser();
   this.redirect(this.landingPage.toString());
   this.modalPoupup.openMyModal();
   }

ModalPopup.ts: has the methods to show/hide the Modal

public openMyModal() { 
   this.myModal.show();
   }

The above code successfully redirects but doesn't open the Modal popup.

If I remove the redirect() in the Login.ts and just have openMyModal(), the modal is shown but when the Modal is closed it still shows the Login page instead of Landing page.

Is it possible to achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耶耶耶 2025-02-03 08:07:48

您可以使用代码 Router.navigate(['page'])在登录完成后重定向页面,您必须导入路由器库。

例子:

login(){
this.userServ.postlogin(this.users)
.subscribe( (res:any) => {
  localStorage.setItem('token',res.token );
  console.log(res)
  this.router.navigate(['private'])
});

}

you can use the code router.navigate(['Page']) to redirect the page after the login is complete, you have to import the Router library.

example:

login(){
this.userServ.postlogin(this.users)
.subscribe( (res:any) => {
  localStorage.setItem('token',res.token );
  console.log(res)
  this.router.navigate(['private'])
});

}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文