# Ember Routing - Dynamic Segment

**URL:** <https://discuss.emberjs.com/t/ember-routing-dynamic-segment/17911>\
**Category:** Questions\
**Created:** [May 23, 2020, 11:14am UTC](https://discuss.emberjs.com/t/ember-routing-dynamic-segment/17911 "2020-05-23T11:14:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruban\_Thilak](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ruban_thilak/32/17054_2.png) [@Ruban\_Thilak](https://discuss.emberjs.com/u/Ruban_Thilak)\
**Post date:** [May 23, 2020, 11:14am UTC](https://discuss.emberjs.com/t/ember-routing-dynamic-segment/17911/1 "2020-05-23T11:14:55Z")

</div>

I am using Ember 3.18 and i have issue with dynamic segment. Here is my `router.js`

```auto
Router.map(function() {

    this.route('posts');

    this.route('post' , {path:"/post/:post_id"});

});

```

When I try to perform a transition from posts route (which contains all the posts) to post/:post\_id (which displays the details of the particular post) using the following

```auto
{{#each this.data as |data|}}
   <LinkTo @route="dashboard.inbox-mail" @model={{data.id}}>
    <div class="card">
      <div>
        <p class="name">{{data.name}}</p>
      </div>
      <div>
        <p class="title">{{data.title}}</p>
        <p class="date">{{data.timestamp}}</p>
      </div>
    </div>
  </LinkTo>
  {{/each}}

```

it does not performs the transition to the post/:post\_id. The data contains following attributes

id - string name - string title - string message - string timestamp - string

my goal is to pass the post id to post/:post\_id and make a API call in the model hook of post/:post\_id.

I was able to perform transition using the below code but the downside is that the beforemodel and model hook are not called. Passing the entire data as model results in not calling the model and beforemodel

```auto
<div>
{{#each this.data as |data|}}
   <LinkTo @route="dashboard.inbox-mail" @model={{data}}>
    <div class="card">
      <div>
        <p class="name">{{data.name}}</p>
      </div>
      <div>
        <p class="title">{{data.title}}</p>
        <p class="date">{{data.timestamp}}</p>
      </div>
    </div>
  </LinkTo>
  {{/each}}
</div>

```

---

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [May 25, 2020, 5:41am UTC](https://discuss.emberjs.com/t/ember-routing-dynamic-segment/17911/2 "2020-05-25T05:41:31Z")

</div>

Hi @Ruban_Thilak, it sounds like you have the right idea, there must be some small mistake that isn’t shown in this code.

Your router.js shows `post` route but your template shows `dasboard.inbox-mail` route. Maybe this is just a copy-paste problem on the forum and not in your app, but make sure you really have the route names the same.

As long as `data.id` is a string or number, it should work the way you want – the `model` hook will run, and receive the id in `params`.
