Can you do multiple dynamic levels in the new deep linker? Does defaultHistory
accept params?
Here’s what I mean. Say you’re doing a taxonomy app and you want a URL/segment scheme that looks something like:
/family/:familyId/genus/:genusId/species/:speciesId
This means the URL for a dog would be:
/family/canidae/genus/canis/species/c_lupus
If you land on the species page, the back button should go to the genus page. But can you send canidae
& canis
back through defaultHistory
as familyId
& genusId
params, like this?
@IonicPage({
name: 'species',
segment: 'family/:familyId/genus/:genusId/species/:speciesId',
defaultHistory: ['family/:familyId/genus/:genusId']
})
I would then want the genus page to have a back button that would send the user back to the family page:
@IonicPage({
name: 'genus',
segment: 'family/:familyId/genus/:genusId',
defaultHistory: ['family/:familyId']
})
But this line from the docs worries me: “This history will only be used if the history doesn’t already exist.” Does this mean that when the user navigates once, the defaultHistory gets preempted?
My hope is that the deep linker is (or will be) smart enough rebuild this full hierarchy.
Or since defaultHistory
“takes an array of strings,” do you do it all in one go by adding a full history of multiple levels, like?
@IonicPage({
name: 'species',
segment: 'family/:familyId/genus/:genusId/species/:speciesId',
defaultHistory: [
'family/:familyId/genus/:genusId',
'family/:familyId'
]
})
That could get unwieldy. If you wanted to do a full taxonomy (species, genus, family, order, class, phylum, kingdom, domain) you’d have to do something like:
defaultHistory: [
'dom/:domId/kin/:kinId/phy/:phyId/cla/:claId/ord/:ordId/fam/:famId/gen/:genId',
'dom/:domId/kin/:kinId/phy/:phyId/cla/:claId/ord/:ordId/fam/:famId',
'dom/:domId/kin/:kinId/phy/:phyId/cla/:claId/ord/:ordId',
'dom/:domId/kin/:kinId/phy/:phyId/cla/:claId',
'dom/:domId/kin/:kinId/phy/:phyId',
'dom/:domId/kin/:kinId',
'dom/:domId'
]
While workable, a param that takes a string for a single page (like defaultBack
, defaultPop
, defaultParent
, or whatever) would make more sense than an array, as long as the deep link system is smart enough to walk up the hierarchy, page-by-page, to build the complete history.
On another note, it might be time to add an “Ionic 3” category to the forum.