# Routing, dynamic parameters, link-to

**URL:** <https://discuss.emberjs.com/t/routing-dynamic-parameters-link-to/6050>\
**Category:** Uncategorized\
**Created:** [August 9, 2014, 6:29pm UTC](https://discuss.emberjs.com/t/routing-dynamic-parameters-link-to/6050 "2014-08-09T18:29:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jehoshua02](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jehoshua02/32/9390_2.png) [@jehoshua02](https://discuss.emberjs.com/u/jehoshua02)\
**Post date:** [August 9, 2014, 6:29pm UTC](https://discuss.emberjs.com/t/routing-dynamic-parameters-link-to/6050/1 "2014-08-09T18:29:23Z")

</div>

I’m trying to get a route like this working:

```javascript
Router.map(function() {
    this.route('due', { path: 'due-:when'});
});

```

And then link to like this:

```nohighlight
{{#link-to 'due' 'past'}}Past Due{{/link-to}}
{{#link-to 'due' 'today'}}Due Today{{/link-to}}
{{#link-to 'due' 'tomorrow'}}Due Tomorrow{{/link-to}}

```

I feel like there is something fundamentally wrong in my understanding of how routing works, even after reading the docs and doing tutorials.

Could somebody please enlighten me?

---

<div class="post-metadata">

**Author:** ![jmonma](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jmonma/32/14803_2.png) [@jmonma](https://discuss.emberjs.com/u/jmonma)\
**Post date:** [August 10, 2014, 1:18pm UTC](https://discuss.emberjs.com/t/routing-dynamic-parameters-link-to/6050/2 "2014-08-10T13:18:45Z")

</div>

Have you tried the path ‘due/:when’?

You can’t have a dynamic _segment_ without it actually being a different segment (‘/’ delimited) of the URL. That should give you what you want.

See “dynamic segments” in the docs:

> **[Defining Your Routes - Routing - Ember Guides](https://guides.emberjs.com/release/routing/defining-your-routes/)**
>
> When your application starts, the router matches the current URL to the routes that you've defined. The routes, in turn, are responsible for displaying templates, loading data, and setting up application state. 
> 
> To define a route, run 
> 
> ember...

If you are interested in seeing how the router parses dynamic segments: [https://github.com/emberjs/ember.js/blob/v1.6.1/packages\_es6/ember-routing/lib/vendor/route-recognizer.amd.js#L95](https://github.com/emberjs/ember.js/blob/v1.6.1/packages_es6/ember-routing/lib/vendor/route-recognizer.amd.js#L95)

---

<div class="post-metadata">

**Author:** ![jehoshua02](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jehoshua02/32/9390_2.png) [@jehoshua02](https://discuss.emberjs.com/u/jehoshua02)\
**Post date:** [August 10, 2014, 3:19pm UTC](https://discuss.emberjs.com/t/routing-dynamic-parameters-link-to/6050/3 "2014-08-10T15:19:01Z")

</div>

Okay, that clears up one piece of the puzzle: dynamic “segments”. Got it. Thanks.

---

<div class="post-metadata">

**Author:** ![jehoshua02](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jehoshua02/32/9390_2.png) [@jehoshua02](https://discuss.emberjs.com/u/jehoshua02)\
**Post date:** [August 10, 2014, 3:25pm UTC](https://discuss.emberjs.com/t/routing-dynamic-parameters-link-to/6050/4 "2014-08-10T15:25:10Z")

</div>

I decided to go with this:

```javascript
Router.map(function() {
  this.resource('tasks', {path: '/'}, function () {
    this.route('dashboard', {path: '/'});
    this.route('due');
    this.route('past-due');
    this.route('due-today');
    this.route('due-tomorrow');
    this.route('due-this-week');
    this.route('due-next-week');
    this.route('due-this-month');
  });
});

```

The number of urls is finite. That’s all my app will support. Adding more would be easy. It’s explicit. I can tell what urls are exposed just by looking at the router.

But now to figure out [the next question](http://stackoverflow.com/questions/25226088/in-ember-multiple-urls-same-route-controller-view-logic-different-filter).
