Unexpected Error: Cannot read property 'nativeElement' of null

I don’t understand what happens this code last week was working without error but today
everything fail.

Post errors as text. Post code as code.

code:

let erroalert1 = this.alertCtrl.create({
        title: 'error',
        subTitle: ' wrong number',
        buttons: ['next']
    });
    erroalert1.present();
} else {
    let alert = this.alertCtrl.create({
        title: "activation code has send to your number ",
        inputs: [{
            name: 'activationcode',
            placeholder: '4 digits activation code'
        }],
        buttons: [{
                text: 'next',
                role: 'next',
                handler: data => {
                    this.http.get(mydonain:8081/chekverification/' + this.UID + '/' + data.activationcode)
                        .map(res => res.text())
                        .subscribe(Token => {
                            console.log(Token);
                            if (Token.length == 21  ) {
                                console.log('correct');
                                this.navCtrl.push(DashboardPage, {UDI: this.UID, Token: Token});
                                this.navCtrl.setRoot(DashboardPage, {UDI: this.UID, Token: Token});
                                this.navCtrl.popToRoot();

                                /*NativeStorage.setItem('UserDeviceauth', {
                                        UDI: this.UID, 
                                        Token: this.Token,
                                        phonenumber: this.phoneNumber                                                        
                                    })
                                    .then(
                                        () => console.log('Stored item!'),
                                        error => console.error('Error storing item', error)
                                    );*/

                            }else{
                                console.log('incorrect');
                              let erroalert2 = this.alertCtrl.create({
                              title: 'Error',
                              subTitle: ' error 2',
                              buttons: [
                                  {
                                    text: 'Cancel',
                                    role: 'cancel',
                                    handler: () => {
                                             erroalert2.dismiss();
                                }}],
                              
                              });
                              erroalert2.present();
                            }
                             alert.present();
                        });
                }
            },
            {
                text: 'send again',
                role: 'retry',
                handler: data => {
                    this.GetActivation();
                }
            }
        ]
    });
    alert.present();
}

}, error => {
console.log(JSON.stringify(error.json()));
});
}

error:

 Cannot read property 'nativeElement' of null
 Stack
 TypeError: Cannot read property 'nativeElement' of null
     at AlertMdPopIn.init (http://localhost:8100/build/main.js:107737:46)
     at OverlayPortal.NavControllerBase._trnsStart (http://localhost:8100/build/main.js:30036:20)
     at AlertMdPopIn._trnsStart (http://localhost:8100/build/main.js:30002:19)
     at AlertMdPopIn.Transition.start (http://localhost:8100/build/main.js:15064:33)
     at OverlayPortal.NavControllerBase._transition (http://localhost:8100/build/main.js:30019:24)
     at OverlayPortal.NavControllerBase._postViewInit (http://localhost:8100/build/main.js:29881:18)
     at OverlayPortal.NavControllerBase._viewTest (http://localhost:8100/build/main.js:29968:25)
     at OverlayPortal.NavControllerBase._nextTrns (http://localhost:8100/build/main.js:29740:25)
     at ti.resolve (http://localhost:8100/build/main.js:29665:19)
     at OverlayPortal.NavControllerBase._trnsFinish (http://localhost:8100/build/main.js:30136:9)

I tried to get this code into a scratch project, but couldn’t even figure out how to make it syntactically correct. Can you isolate it into something that can just be copied/pasted into an otherwise blank page?

Dear @rapropos I think I had to improve this code. but i will do what you suggested. and will past it here.