Basic Alert Sample Code is not working

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

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();
}

}

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

1 Like

@pasumarthivijaykumar

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

Thanks a lot for quick reply.