# Component lifecycle in ionic

**URL:** <https://forum.ionicframework.com/t/component-lifecycle-in-ionic/100336>\
**Category:** ionic-v3\
**Created:** [August 1, 2017, 6:07am UTC](https://forum.ionicframework.com/t/component-lifecycle-in-ionic/100336 "2017-08-01T06:07:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashley\_shookhye](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@ashley\_shookhye](https://forum.ionicframework.com/u/ashley_shookhye)\
**Post date:** [August 1, 2017, 6:07am UTC](https://forum.ionicframework.com/t/component-lifecycle-in-ionic/100336/1 "2017-08-01T06:07:56Z")

</div>

Hello, I have built a component as follows

```auto

export class AcknowledgementComponent implements AfterViewInit {

  private description: string;

  @Input('period') period: string;
  constructor() {
  }

  ngAfterViewInit() {
    console.log(this.period)
  }

```

I have to perform some logic with that variable before using it in the template. But in ngOnInit and ngAfterViewInit, the variable is undefined. Can someone advise which hook to use in order to get the variable?

---

<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:** [August 1, 2017, 7:55am UTC](https://forum.ionicframework.com/t/component-lifecycle-in-ionic/100336/2 "2017-08-01T07:55:25Z")

</div>

`ngOnChanges()` is the only reliable place to reference input properties.

---

<div class="post-metadata">

**Author:** ![ashley\_shookhye](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@ashley\_shookhye](https://forum.ionicframework.com/u/ashley_shookhye)\
**Post date:** [August 1, 2017, 8:01am UTC](https://forum.ionicframework.com/t/component-lifecycle-in-ionic/100336/3 "2017-08-01T08:01:23Z")

</div>

Hello. Thanks for the reply. Does not get neither the current or previous value though.

Ashley.
