2

We are working on an Angular app which includes a lot of nested views.

I will give a brief example here,

  1. We have a Cities,
  2. A city can have multiple regions
  3. A region has list of schools
  4. School has classes
  5. A class has students and student can have his details.

This is just a part of the app, we have many such other nested routes.

Now, the way I have configured the route is -

 .state('city', {
   url: '/city'
   // Other stuff removed for sanity
 })
 .state('city.details', {
   url: '/:cityId/details'
   // Other stuff removed for sanity
 })
 .state('city.schools', {
   url: ':cityId/schools'
   // Other stuff removed for sanity
 })
 .state('city.schools.details', {
   url: '/:schoolId/details'
   // Other stuff removed for sanity
 })
 .state('city.schools.students', {
   url: '/:schoolId/students'
   // Other stuff removed for sanity
 })
 .state('city.schools.students.details', {
   url: '/:studentId/details'
   // Other stuff removed for sanity
 })
 .state('city.schools.students.timeline', {
   url: '/:studentId/timeline'
   // Other stuff removed for sanity
 })
 .state('city.schools.students.timeline.details', {
   url: '/:timelineId/details'
   // Other stuff removed for sanity
 })

The routing is something similar to this. Everything works just perfectly fine, However when I am at the deepest route especially with Guids as unique identifier i.e.

https://www.contoso.com/#/city/949C3148-5E74-41E2-BF2A-17C49FBCC15F/schools/4DE61D87-0DFB-445E-B4B0-3E1A3BB1DB30/students/EF56D682-BCFB-4431-A5EF-7F1F8CF4915D/timeline/14442B0A-0856-4269-A771-3B1BA8B283D1/details

This is way too long URL and is not user friendly if I am not wrong.

Is there any room for optimizing this sort of route? Any expert advice would be helpful.

Rahul.

Rahul Patil
  • 5,656
  • 6
  • 37
  • 65
  • Could you use a hashcode - see http://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery – Kevin Friedheim May 28 '16 at 06:25
  • Do this states must be nested? Could you just use `/timeline/yyy`, even if you use `long`s for id's it still would be too long for my taste. – csharpfolk May 28 '16 at 07:58

0 Answers0