I have a workflow where users can edit a song's information. When a user is on a song page, they can click the edit button to bring up the editing page. For example if a user is viewing a submission and would like to edit, they would go from the release page to the submit page using navigateByURL(tabs/(submit:submit/:artist/:submission)
:
/tabs/(home:release/isrk2mpkiq)
to ->
/tabs/(submit:submit/2zmrsXMHxagFz6vI2cD7r6/isrk2mpkiq)
(note how these are on two different tabs/outlets: Home and Submit)
Edit mode is determined by subscribing to the route params and if an :artist
(2zmrsXMHxagFz6vI2cD7r6) and :submission
(isrk2mpkiq) are present in the url then we know to display the edit prompt (with all of the details filled in to the inputs) instead of the empty submission prompt, using the following within the ngOnInit()
on the submit page:
this.route.params.subscribe(
(params: Params) => {
if (params['artist'] && params['submission']) {
this.submissionEdit(params['artist'], params['submission'])
}
}
)
Once the user completes the edit, the updates are saved and the user is routed back to the submission page (thus moving away from the submit tab) with:
navigateByUrl('tabs/(home:release/${this.submission.submissionUID})')
Everything works perfectly until the user clicks the edit button on the song page again
When they do, they are routed back to that submit page url, but since the route had not changed on the submit tab, the route params subscription didn't update and could not run the this.submissionEdit()
method inside the subscription thus not populating the submission form with existing data.
So my question is, after the user submits an edit, how do I reset the specific submit tab/stack back to tabs/(submit:submit)
so that when the user clicks edit again, the url does change and that param subscription can update?
I am using Ionic 4 Angular. Let me know what other info you may need, thanks!
ionTabsWillChange
, inject the@ViewChild('appTabs')
and dothis.appTabs.select(event.tab)
. The only thing is that this will cause the stacked view to be shown first and animated away. – ciekawy