# Basic Alert Sample Code is not working

**URL:** <https://forum.ionicframework.com/t/basic-alert-sample-code-is-not-working/122791>\
**Category:** ionic-v3\
**Created:** [February 27, 2018, 6:33am UTC](https://forum.ionicframework.com/t/basic-alert-sample-code-is-not-working/122791 "2018-02-27T06:33:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pasumarthivijaykumar](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/pasumarthivijaykumar/32/117542_2.png) [@pasumarthivijaykumar](https://forum.ionicframework.com/u/pasumarthivijaykumar)\
**Post date:** [February 27, 2018, 6:33am UTC](https://forum.ionicframework.com/t/basic-alert-sample-code-is-not-working/122791/1 "2018-02-27T06:33:58Z")

</div>

I have followed and prepared a sample application for ‘Basic Alert’, but i an getting error as below,  
**TypeError: this.navCtrl1.create is not a function**

> **[Ionic Framework](https://ionicframework.com/docs/components/#alert)**
>
> Ionic is the app platform for web developers. Build amazing mobile, web, and desktop apps all with one shared code base and open web standards

the code which is explained, does not work for me. Can someone help me here ?

My code details as below mentioned.

\<button ion-button block color=“blue” (click)=“sayHello()”\> Say Hello!!!

import { Component } from ‘@angular/core’;  
import { NavController } from ‘ionic-angular’;

@Component({  
selector: ‘page-home’,  
templateUrl: ‘home.html’  
})  
export class HomePage {

constructor(public navCtrl1: NavController) { }

sayHello(){  
let alert = this.navCtrl1.create({  
title: ‘Hi’,  
subTiltle: ‘Welcome to Mobile Program’,  
bottons: [‘OK’]  
});  
alert.present();  
}

}

---

<div class="post-metadata">

**Author:** ![felix9607](https://avatars.discourse-cdn.com/v4/letter/f/0ea827/32.png) [@felix9607](https://forum.ionicframework.com/u/felix9607)\
**Post date:** [February 27, 2018, 6:39am UTC](https://forum.ionicframework.com/t/basic-alert-sample-code-is-not-working/122791/2 "2018-02-27T06:39:24Z")

</div>

Are you for real?

You couldn’t copy paste the sample Code?  
You try to create an `Alert` with a `NavigationController` (`navCtrl1`).  
Change it to `AlertController`

---

<div class="post-metadata">

**Author:** ![vibinflogesoft](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/vibinflogesoft/32/117525_2.png) [@vibinflogesoft](https://forum.ionicframework.com/u/vibinflogesoft)\
**Post date:** [February 27, 2018, 6:43am UTC](https://forum.ionicframework.com/t/basic-alert-sample-code-is-not-working/122791/3 "2018-02-27T06:43:27Z")

</div>

@pasumarthivijaykumar

```auto
constructor(public alertCtrl: AlertController) { }

sayHello(){
let alert = this.alertCtrl.create({
title: ‘Hi’,
subTiltle: ‘Welcome to Mobile Program’,
bottons: [‘OK’]
});
alert.present();
}
Change your code like this

```

---

<div class="post-metadata">

**Author:** ![pasumarthivijaykumar](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/pasumarthivijaykumar/32/117542_2.png) [@pasumarthivijaykumar](https://forum.ionicframework.com/u/pasumarthivijaykumar)\
**Post date:** [February 27, 2018, 6:49am UTC](https://forum.ionicframework.com/t/basic-alert-sample-code-is-not-working/122791/4 "2018-02-27T06:49:05Z")

</div>

Thanks a lot for quick reply.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:48pm UTC](https://forum.ionicframework.com/t/basic-alert-sample-code-is-not-working/122791/5 "2021-07-19T21:48:48Z")

</div>

Closed on July 19, 2021, 9:48pm UTC


