angular - alert message using ionic2 -
when click register button ,if enter fields going regsuccess page got message fill required feilds.
but want show message alert using ionic2 , typescript.
html:
<button primary full (click)="register()" >register</button> <p>{{regmsg}}</p>
.ts file:
register(){ var _this= this; // this.submitattempt = true; if(!this.registrationform.valid){ _this.regmsg = "enter required feilds"; } else { console.log("success!") console.log(this.registrationform.value); _this.navctrl.setroot(regthankyoupage); }
import { alertcontroller } 'ionic-angular'; // import alert controller export class mycomponent { regmsg: string; constructor(public alertcontroller: alertcontroller) {} showerrormsg(msg) { let alert = this.alertctrl.create({ title: msg, subtitle: '10% of battery remaining', buttons: ['dismiss'] }); alert.present(); } register(){ if (!this.registrationform.valid) { this.regmsg = "enter required feilds"; console.log("form invalid"); this.showerrormsg(this.regmsg); } else { console.log("valid form"); } } }
Comments
Post a Comment