mardi 23 octobre 2018

Ember - Optional Dynamic Segments in Route

I have a use case and I’m not sure if there is an easy solution within the current Ember router or not, is there a way to define an optional routing param?

I would like to have a dynamic route that might have 1 or might have 2 segments, and then further routes nested inside. My idea of the structure would be something like the below (except the :topic part would be optional)

this.route('course', { path: '/:course' }, function() {
  this.route('page', { path: '/:topic/:page' }, function() {
    this.route('menu', function() {

    });
  });
});

/my-course/my-topic/my-page would hit the page route

/my-course/my-page would hit the page route

/my-course/my-page/menu would hit the menu route

/my-course/my-topic/my-page/menu would hit the menu route




Aucun commentaire:

Enregistrer un commentaire