# Alert not working

**URL:** <https://forum.ionicframework.com/t/alert-not-working/56403>\
**Category:** ionic-v3\
**Created:** [July 1, 2016, 12:33pm UTC](https://forum.ionicframework.com/t/alert-not-working/56403 "2016-07-01T12:33:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelvinrolex](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kelvinrolex/32/101032_2.png) [@kelvinrolex](https://forum.ionicframework.com/u/kelvinrolex)\
**Post date:** [July 1, 2016, 12:33pm UTC](https://forum.ionicframework.com/t/alert-not-working/56403/1 "2016-07-01T12:33:34Z")

</div>

Please i have been trying to implement the Alert component in my ionic project but i keep getting this error (TypeError: Cannot read property ‘present’ of undefined), this happens when i insert the line of code (this.nav.present(alert)😉 at the end and without this code it won’t work. Below is my code

onConfirm() {  
let alert = Alert.create({  
title: ‘Attention’,  
subTitle: ‘hey there’,  
buttons: [“Yes”]  
})  
this.nav.present(alert);  
}

The error that is showing on google chrome inspect element is attached

 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/6/1/61c2ce8228397b28343ea4c0e406907dfe1b5e89.PNG)

Please help me with solution.

---

<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:** [July 1, 2016, 7:52pm UTC](https://forum.ionicframework.com/t/alert-not-working/56403/2 "2016-07-01T19:52:24Z")

</div>

The error message is telling you exactly what is wrong. `this.nav` is undefined.

---

<div class="post-metadata">

**Author:** ![kelvinrolex](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kelvinrolex/32/101032_2.png) [@kelvinrolex](https://forum.ionicframework.com/u/kelvinrolex)\
**Post date:** [July 2, 2016, 5:48am UTC](https://forum.ionicframework.com/t/alert-not-working/56403/3 "2016-07-02T05:48:51Z")

</div>

Sorry I don’t understand you when you say this.nav is not define, I think it is defined in the constructor like this (this.nav = nav), or is that not what you are referring to?

---

<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:** [July 4, 2016, 6:24pm UTC](https://forum.ionicframework.com/t/alert-not-working/56403/4 "2016-07-04T18:24:33Z")

</div>

> [@kelvinrolex](#):
>
> I think it is defined in the constructor like this (this.nav = nav)

`undefined` is a primitive value in JavaScript. In the statement you mention, if the right hand side (“nav”) is `undefined`, so will be `this.nav`. Whereever you are getting `nav` from isn’t working.

---

<div class="post-metadata">

**Author:** ![kelvinrolex](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kelvinrolex/32/101032_2.png) [@kelvinrolex](https://forum.ionicframework.com/u/kelvinrolex)\
**Post date:** [July 4, 2016, 9:21pm UTC](https://forum.ionicframework.com/t/alert-not-working/56403/5 "2016-07-04T21:21:56Z")

</div>

I just figured where the problem is, in my export class i have something like this

export class AdmissionsPage {  
static get parameters() {  
return [[Platform]];  
}

if i remove the static get parameters() it will work, like this  
export class AdmissionsPage {

}.

The problem now is that i can’t remove those parameters because am using it to call inappbrowser plugin, pls do u have any idea on what i can do to keep those parameters and also have the alert working?

---

<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:** [July 5, 2016, 12:38am UTC](https://forum.ionicframework.com/t/alert-not-working/56403/6 "2016-07-05T00:38:52Z")

</div>

If you’re using TypeScript, just type it as a constructor argument:

```auto
class AdmissionsPage {
  constructor(private _plat:Platform) {
    _plat.ready().then(() => {
      // do stuff
    });
  }

  anotherMethod() {
    // this._plat is still visible here
  }
}

```

If your project is JavaScript, my only advice is “switch to TypeScript”, but perhaps somebody else will have other suggestions. I can’t stand JavaScript, and have done everything in my power to avoid it as much as possible.

---

<div class="post-metadata">

**Author:** ![kelvinrolex](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kelvinrolex/32/101032_2.png) [@kelvinrolex](https://forum.ionicframework.com/u/kelvinrolex)\
**Post date:** [July 5, 2016, 11:05am UTC](https://forum.ionicframework.com/t/alert-not-working/56403/7 "2016-07-05T11:05:31Z")

</div>

ok thanks…i am using typescript, its working now…
