# Accessing a parent's view element

**URL:** <https://forum.ionicframework.com/t/accessing-a-parents-view-element/172858>\
**Category:** ionic-v3\
**Created:** [September 9, 2019, 4:03pm UTC](https://forum.ionicframework.com/t/accessing-a-parents-view-element/172858 "2019-09-09T16:03:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lqrz](https://avatars.discourse-cdn.com/v4/letter/l/a9a28c/32.png) [@lqrz](https://forum.ionicframework.com/u/lqrz)\
**Post date:** [September 9, 2019, 4:03pm UTC](https://forum.ionicframework.com/t/accessing-a-parents-view-element/172858/1 "2019-09-09T16:03:47Z")

</div>

I have a component `my_component` with a `ion-content`, which im using inside one of my pages `my_page`, which also has another `ion-content`.

Because I need to do some manual handling of the scrolling, I need to be able to access the ion-content element of `my_page` from the component (that is, from `my_component.ts`).

Is there a way of doing this?

Thanks!

```auto
//--------------- my_component.html
<ion-content>
    ...
</ion-content>

```

```auto
//--------------- my_page.html

<ion-content>
    ...
    <my_component></my_component>
    ...
</ion-content>

```

```auto
//--------------- my_component.ts

export class MyComponent {

    // Here, I need a ref to my_page <ion-content>
    @ViewChild(Content) content: Content;
    
    constructor() { ... }
}

```

---

<div class="post-metadata">

**Author:** ![crmontiel](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/crmontiel/32/127900_2.png) [@crmontiel](https://forum.ionicframework.com/u/crmontiel)\
**Post date:** [September 9, 2019, 4:35pm UTC](https://forum.ionicframework.com/t/accessing-a-parents-view-element/172858/2 "2019-09-09T16:35:11Z")

</div>

Hello, you can only manipulate direct data on the child component, in order to manipulate the content of the parent component, you need to handle events that the child envies the father.

```auto
//--------------- my_page.html

<ion-content>
    ...
    <my_component (myAction)="functionToAction($event)"></my_component>
    ...
</ion-content>

```

Ts myPage

```auto
//--------------- my_page.ts
functionToAction(event){
//write you comand.
}

```

You MyComponent

```auto
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
export class MyComponentFather {

    // Here, evento to you " my_page <ion-content>"
  @Output() myAction: EventEmitter<any> = new EventEmitter<any>();
   
    
    constructor() { ... }

  sendActionTomy_page(){
    this.myAction.emit(data)
  }
}

```

---

<div class="post-metadata">

**Author:** ![Tommertom](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@Tommertom](https://forum.ionicframework.com/u/Tommertom)\
**Post date:** [September 9, 2019, 7:29pm UTC](https://forum.ionicframework.com/t/accessing-a-parents-view-element/172858/3 "2019-09-09T19:29:41Z")

</div>

[https://angular.io/guide/component-interaction](https://angular.io/guide/component-interaction)

A service with BehaviorSubject too?
