# How can I access an "ion-content" element that's inside a component?

**URL:** <https://forum.ionicframework.com/t/how-can-i-access-an-ion-content-element-thats-inside-a-component/82496>\
**Category:** ionic-v3\
**Created:** [March 10, 2017, 5:15pm UTC](https://forum.ionicframework.com/t/how-can-i-access-an-ion-content-element-thats-inside-a-component/82496 "2017-03-10T17:15:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![odorakel](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/odorakel/32/101000_2.png) [@odorakel](https://forum.ionicframework.com/u/odorakel)\
**Post date:** [March 10, 2017, 5:15pm UTC](https://forum.ionicframework.com/t/how-can-i-access-an-ion-content-element-thats-inside-a-component/82496/1 "2017-03-10T17:15:54Z")

</div>

Hey folks,

I have a problem and I was looking for a solution all day long, but I’ve given up. Hopefully you might have a solution…

Let’s say - I have a component A. The template and the css are also included inside the component code - containing an `<ion-content #scroller>....</ion-content>` element.

My question: How can I access this “ion-content” element from my regular page via “`ViewChild`”? I would **like to perform some scroll actions** , but it’s not working and I really tried almonst everything. :frowning

Thanks,  
Oliver

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [March 10, 2017, 11:35pm UTC](https://forum.ionicframework.com/t/how-can-i-access-an-ion-content-element-thats-inside-a-component/82496/2 "2017-03-10T23:35:23Z")

</div>

I must be misunderstanding something, because it looks to me like [that exact situation is described in the Content docs](https://ionicframework.com/docs/v2/api/components/content/Content/).

---

<div class="post-metadata">

**Author:** ![odorakel](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/odorakel/32/101000_2.png) [@odorakel](https://forum.ionicframework.com/u/odorakel)\
**Post date:** [March 13, 2017, 8:39am UTC](https://forum.ionicframework.com/t/how-can-i-access-an-ion-content-element-thats-inside-a-component/82496/3 "2017-03-13T08:39:00Z")

</div>

This example shows only how to get the reference for the `<ion-content />` on the same page. The component I would like to access is on a template of the components component… It’s a add-on component with it’s own template.

---

<div class="post-metadata">

**Author:** ![Kalu06](https://avatars.discourse-cdn.com/v4/letter/k/439d5e/32.png) [@Kalu06](https://forum.ionicframework.com/u/Kalu06)\
**Post date:** [December 9, 2018, 3:59pm UTC](https://forum.ionicframework.com/t/how-can-i-access-an-ion-content-element-thats-inside-a-component/82496/4 "2018-12-09T15:59:46Z")

</div>

Hi odorakel,

You probably already figured out a solution to your problem.

For those still interested, I needed exactly the same thing and here’s how I did it:

**Parent**

```auto
<!-- parent.html (the one defining <ion-content> tag) -->
<ion-content #scroller>
  <child [scroller]="scroller"></child>
</ion-content>

```

**Child**

```auto
/* child.ts (the one using ion-content reference) */
import { Component, Input } from '@angular/core';

@Component({
  selector: 'child',
  templateUrl: 'child.html',
})
export class ChildComponent {
  @Input() public scroller: any; // <== Gives you access to ion-content (via ref scroller)
  [...]
}

```

Hope this helps.

Cheers,  
Lucas
