I've been following Brian Love's tutorial to create a breadcrumb:
http://brianflove.com/2016/10/23/angular2-breadcrumb-using-router/
<http://www.google.com/url?q=http%3A%2F%2Fbrianflove.com%2F2016%2F10%2F23%2Fangular2-breadcrumb-using-router%2F&sa=D&sntz=1&usg=AFQjCNFPLXroDZi4MfvAV-dr2fBwW-fdEA>
My question isn't about his tutorial but rather about how ActivatedRoute
works.
Imagine you have an app that follows down this hierarchical path:
Countries > States_Provinces > Cities_Towns
Now suppose you've been requested for the breadcrumb to follow this format:
1. At the Countries level, show no breadcrumb
2. At the States/Provinces level, show a breadcrumb in this format:
Country: *CountryName*
3. At the Cities/Towns level, show a breadcrumb in this format:
Country: *CountryName* / State/Province: *StateProvinceName*
Assume that each of your Country names have a 0-based index and that each
of your State/Province names have their own 0-based index.
The "weird" thing I find about how ActivatedRoute works is how it works its
way down the hierarchy. Following along with the code provided by Brian
Love's tutorial, his recursive *getBreadcrumbs* function returns these
cumulative *url* values:
- url: /dashboard
- url: /dashboard/
- url: /dashboard//countries
- url: /dashboard//countries/
- url: /dashboard//countries//0/statesProvinces
- url: /dashboard//countries//0/statesProvinces/
- url: /dashboard//countries//0/statesProvinces//0
I find this very peculiar. Remember that every time your code detects a
numeric value, it has to extract it, look up the English name associated
with that id and display it instead.
Anyhow, I'm just wondering if anyone with more experience with
ActivatedRoute has encountered something similar and can offer advice on
how they handled this predicament.
Robert
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.