Show alert during start of the app

how to show an alert when you start your application ? it works good on click but how to initiate the alert during the start of the app.

Wrap your Alert in either

onPageLoaded(){}
onPageWillEnter(){}

or
onPageDidEnter(){}

in yourr start page.

See “LifeCycle Events” at

1 Like

you can always rise the alert on your “first” controller, the easiest way.

.controller('FirstCtrl', function($scope, ) {

alert('Hey you!');

...
...
})

thanks sir, but i think it is for Ionic 1 …can you provide the same for angularjs 2?

thanks…works like a charm :smile:

but one thing is there @Mobius77
when I am putting the inside the constructor, alert do come up but the main page gets totally blank.
and after pressing OK button on the alert it closes the alert and white blank page comes up.
any idea how to solve this?

Do not put inside constructor :slight_smile:

constructor(private nav:NavController){
  blah blah
 }

  onPageLoaded(){
     let myAlert=Alert.create({
                            title: 'Example',
                            message: "This is an example",
                            enableBackdropDismiss:false,
                            buttons: ['OK']
                        })
     this.nav.present(myAlert);
  }