# Access router dependency from child

**URL:** https://forums.fusetools.com/t/access-router-dependency-from-child/5925
**Category:** How-to Discussions
**Created:** [April 27, 2017, 7:44am UTC](https://forums.fusetools.com/t/access-router-dependency-from-child/5925 "2017-04-27T07:44:52Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Palton](https://avatars.discourse-cdn.com/v4/letter/p/3d9bf3/32.png) [@Palton](https://forums.fusetools.com/u/Palton)
#### Post date: [April 27, 2017, 7:44am UTC](https://forums.fusetools.com/t/access-router-dependency-from-child/5925/1 "2017-04-27T07:44:52Z")

</div>

Hi!

I have a MainView with a Navigator component. The logic for pushing a path is done in Javascript inside a Class named FooterComponent.

```auto
/* The function that pushes the path to the router */
var gotoPage = function(args) { 
    setIcon(args); 
    router.push( 'feed', {} );
};

```

Whenever I click the button/icon for navigating to the page I get the following error:

Error message: Uncaught ReferenceError: router is not defined

As the error suggests, I dont have a reference to the router from within the child class FooterComponent. How would I go about to get a reference to the router from within the component?

I tried adding this to the top of the class without any luck.

```auto
<Router ux:Dependency="router"/>

```

---

<div class="post-metadata">

### Author: ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)
#### Post date: [April 27, 2017, 7:50am UTC](https://forums.fusetools.com/t/access-router-dependency-from-child/5925/2 "2017-04-27T07:50:57Z")

</div>

Hi Palton,

not only you have to specify the dependency, but you also have to satisfy it by passing the router along the UX path.

Check the [Navigation docs](https://www.fusetools.com/docs/navigation/navigation#creating-pages) and the Navigation section in [Fuse Tutorial](https://www.fusetools.com/docs/tutorial/navigation-and-routing#routing-with-router), which both cover this nicely.

Hope this helps!

---

<div class="post-metadata">

### Author: ![Palton](https://avatars.discourse-cdn.com/v4/letter/p/3d9bf3/32.png) [@Palton](https://forums.fusetools.com/u/Palton)
#### Post date: [April 27, 2017, 8:04am UTC](https://forums.fusetools.com/t/access-router-dependency-from-child/5925/3 "2017-04-27T08:04:52Z")

</div>

Hi Uldis!

Thanks for the reply!

I have added the dependency using

MainView.ux:

```auto
<Router ux:Name="router"/>

```

Page.ux:

```auto
<Router ux:Dependency="router"/>

```

And finally inside the FooterComponent which is placed onto the Page.ux:

```auto
<Router ux:Dependency="router"/>

```

Is there anything missing?

---

<div class="post-metadata">

### Author: ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)
#### Post date: [April 27, 2017, 8:10am UTC](https://forums.fusetools.com/t/access-router-dependency-from-child/5925/4 "2017-04-27T08:10:13Z")

</div>

Yes Palton, there is something missing. The part about “you also have to satisfy the dependencies”. Which is also explained very well in the two links that I posted earlier.

Here, you specify the dependency:

```auto
<Page ux:Class="HomePage">
    <Router ux:Dependency="router" />

```

and then you pass it, when you’re using the ux:Class:

```auto
<App>
    <Router ux:Name="router" />

    <ClientPanel>
        <Navigator DefaultPath="home">
            <HomePage ux:Template="home" router="router" />

```

---

<div class="post-metadata">

### Author: ![Palton](https://avatars.discourse-cdn.com/v4/letter/p/3d9bf3/32.png) [@Palton](https://forums.fusetools.com/u/Palton)
#### Post date: [April 27, 2017, 8:13am UTC](https://forums.fusetools.com/t/access-router-dependency-from-child/5925/5 "2017-04-27T08:13:40Z")

</div>

Ahh, that would do it! That missed my attention.

Thank you!
