# In nested routing when i link from child route to parent route the parent route model is not loading

**URL:** <https://discuss.emberjs.com/t/in-nested-routing-when-i-link-from-child-route-to-parent-route-the-parent-route-model-is-not-loading/19860>\
**Category:** Routing\
**Created:** [December 30, 2022, 6:43am UTC](https://discuss.emberjs.com/t/in-nested-routing-when-i-link-from-child-route-to-parent-route-the-parent-route-model-is-not-loading/19860 "2022-12-30T06:43:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sriakran](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@Sriakran](https://discuss.emberjs.com/u/Sriakran)\
**Post date:** [December 30, 2022, 6:43am UTC](https://discuss.emberjs.com/t/in-nested-routing-when-i-link-from-child-route-to-parent-route-the-parent-route-model-is-not-loading/19860/1 "2022-12-30T06:43:02Z")

</div>

Hi, I’m newbie to ember when I call the parent route using `<LinkTo>` The model of that route is not loading but when I call the neighbor route of that child route the model is loading, What should i do to load the parent routs model

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [December 30, 2022, 3:59pm UTC](https://discuss.emberjs.com/t/in-nested-routing-when-i-link-from-child-route-to-parent-route-the-parent-route-model-is-not-loading/19860/2 "2022-12-30T15:59:50Z")

</div>

Hi Sriakran, could you share more details about the route hierarchy and what you want to happen? It’s a little difficult to diagnose without a bit more context.

One thing to note though, is that a parent route model is only going to load when it is first visited, it doesn’t reload anytime you change child routes. For example, if you visit:

```auto
/parent/child1 // parent model hook will load, child1 model hook will load
/parent/child2. // parent model hook will not reload, child2 model hook will load
/parent // parent model hook will not reload
/other-route // outside of parent route, other-route model will load
/parent/child2 // parent model hook will load, child2 model hook will load
```

---

<div class="post-metadata">

**Author:** ![Sriakran](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@Sriakran](https://discuss.emberjs.com/u/Sriakran)\
**Post date:** [January 1, 2023, 12:26pm UTC](https://discuss.emberjs.com/t/in-nested-routing-when-i-link-from-child-route-to-parent-route-the-parent-route-model-is-not-loading/19860/3 "2023-01-01T12:26:41Z")

</div>

@dknutsen thanks for the time, by the way I found the solution [here](https://discuss.emberjs.com/t/parent-routes-model-do-not-refresh-when-its-child-route-transition-back-to-parent-route/17148).

---

<div class="post-metadata">

**Author:** ![Aarthi](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/aarthi/32/18480_2.png) [@Aarthi](https://discuss.emberjs.com/u/Aarthi)\
**Post date:** [February 16, 2025, 3:04pm UTC](https://discuss.emberjs.com/t/in-nested-routing-when-i-link-from-child-route-to-parent-route-the-parent-route-model-is-not-loading/19860/4 "2025-02-16T15:04:51Z")

</div>

Hi, i’m facing the same can you help me out?how did you fixed that. i want to hide the current parent route when switching to child route of nested routes?

```auto
Router.map(function () {
    this.route('workspace', { path: '/ws/:workspace_id' }, function () {
    
        this.route('files'); 
      
  });
});

```

during workspace/ws/ route the list of task will b e listed, after clicking any of task, it should be redirected to files route

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [February 17, 2025, 4:23pm UTC](https://discuss.emberjs.com/t/in-nested-routing-when-i-link-from-child-route-to-parent-route-the-parent-route-model-is-not-loading/19860/5 "2025-02-17T16:23:13Z")

</div>

Hi @Aarthi! The important thing to remember is that nested routes mean nested UI.

If I’m understanding what you want correctly then you have two options:

### 1. use nested routes, but put the “workspace” template in the workspace index template instead

This would look like this:

```auto
Router.map(function () {
  this.route('workspace', { path: '/ws/:workspace_id' }, function () {
    // this.route('index'); <-- this route is implicitly created already
    this.route('files'); 
  });
});

// app/templates/workspace.hbs 
     ^ this template should basically just be an "{{outlet}}"
       because this is rendered for `/ws/:id` and ANY sub-route

// app/templates/workspace/index.hbs
     ^ this template should have the list of tasks
       this is what you will see when you visit just `/ws/:id`

// app/templates/workspace/files.hbs
     ^ this stays how it is
       when you visit `/ws/:id/files` you will no longer see the `index` template

```

### 2. don’t use nested routes, allow files to be an independent route

The other option is to just treat files as an independent route. Something like this:

```auto
Router.map(function () {
  this.route('workspace', { path: '/ws/:workspace_id' });
  this.route('files', { path: '/ws/:workspace_id/files' }); 
});

```

I personally like option 1 better.
