lundi 15 mai 2017

Remove dynamic segment information from route emberjs

I have an ember engine, and within that I have defined a route. It works as expected. It's called my-route. It was defined like this:

this.route('my-route', {path: '/my-route/:myparams'}); in the routes.js file.

As you can see, it has a dynamic segment, and shows different values based on myparams.

I want to add a nested route to this route. Let's say .../my-route/1 shows a list of items. When the user clicks on any of the items listed on the page, the route should be: my-route/display but instead its my-route/1/display. I don't want the 1 here as it could be misleading.

Also, the link-to doesn't open anything either, the click does nothing. This is how I changed my routes.jsfile:

this.route('my-route', {path: '/my-route/:myparams'}, function() { this.route('display'); });

In display.hbs file I added dummy data, and display.js is also empty, just extending from Ember.route. The my-route.hbs links like this:

Open me '

I am new to EmberJS, and would appreciate if someone could please tell me how to:

  1. Remove the dynamic segment information
  2. Make the link-to work

Thank you!




Aucun commentaire:

Enregistrer un commentaire