0

My idea is to create an alert in a provider and use it in which ever page its needed.so I wrote this code in provider

constructor(public alertCtl:AlertController) {
    
  }
presentDismissAlert(  navCtrl: NavController) {
  let alert = this.alertCtl.create({
                    title: 'connect your charger',
                    subTitle: '10% is remaining',
                    buttons: ['Dismiss']
        });
  navCtrl.present(alert);   
 }

and in a page I am calling this method as follows

constructor(public navCtrl: NavController, public navParams: NavParams,public alt : alertProvider ) {
   this.altCtrl.presentDismissAlert(this.navCtrl);
        }

but this error remains ` Property 'present' does not exist on type 'NavController'.

  L22:         });
  L23:   navCtrl.present(alert);   

`any help regarding this

Lisa
  • 655
  • 3
  • 10
  • 34

1 Answers1

2

You dont need navController to present alert. Check here.

presentDismissAlert() {
        let alert = this.alertCtl.create({
                    title: 'connect your charger',
                    subTitle: '10% is remaining',
                    buttons: ['Dismiss']
        });
     alert.present()   
    }
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103