Angular Router-返回,我的组件不会从0重置。因此工作错误
我正在构建一个离子角应用程序,并构建一个寄存器功能,用户逐步进入我要求它们的数据。
用户可以向后移动(我配置了一个后箭头按钮,如果单击,则将返回到上一个步骤的路由),但是在执行此操作时,我刚刚打开的“上一个步骤”组件无法正常工作。 它看起来相同,但是我在TS文件的属性中声明的某些数据由于某种原因而丢失,因此功能不能很好地工作。
我认为这是该组件的生命周期问题,因为它可能根本没有重置,因为它养了打开的最后一个组件。 (只是猜测)
当单击时,我将分配的功能放在后面按钮上:
goBackInNavegation() {
this.router.navigate(['../step2'], { relativeTo: this.activatedRoute, state: {activity: this.activity}}); }
忽略我使用“活动”传递的状态对象。
如果上一个导航是从上一个步骤(组件IM导航到该功能中的组件),我该如何将该组件重置为实际的步骤IM?
感谢任何帮助。 ty :)
I'm building an ionic-angular app, and building a Register functionality, where the user goes step by step entering the data that I ask them for.
The user can go backwards (I configured a back arrow button, where if clicked they go back to the route of the previous step), but when doing this, this "previous step" component I just opened won't work as expected.
It looks the same, but some of the data I declare in the properties of the ts file are lost for some reason, so functionality does not work well.
I think it is a lifecycle issue of the component, because it maybe does not reset at all due to it beeing the last component that was openened. ( Just guessing )
I leave the function assigned to the back button when clicked:
goBackInNavegation() {
this.router.navigate(['../step2'], { relativeTo: this.activatedRoute, state: {activity: this.activity}}); }
Ignore the state object I pass with the "activity".
How do I reset that component I navigate to if the previous navigation was from that previous step (the component im navigating to in the function) to the actual step Im in?
I appreciate any help. Ty :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在
ngoninit()
中初始化组件?当您返回时,该功能不会被调用。
如果您每次进入时都要启动数据,则必须在
ionviewwillenter
检查此
Are you initializing the component inside
ngOnInit()
?When you go back that function won't be called.
If you want to init data every time you go in, you have to do inside
ionViewWillEnter
check this