0
votes

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

1

1 Answers

2
votes

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