import { Component } from '@angular/core' ; import { NavController } from 'ionic-angular' ; import { AlertController } from 'ionic-angular' ; import { UserRegistrationService , IUserRegistration } from '../../services/account-management.service' ; import { AccountConfirmationCodePage } from '../account-confirmation-code/account-confirmation-code' ; import { GlobalStateService } from '../../services/global-state.service' ; import { Logger } from '../../services/logger.service' ; @ Component ( { selector : 'account-signup' , templateUrl : 'account-signup.html' } ) export class AccountSignupPage { accountConfirmationCodePage = AccountConfirmationCodePage ; public userData : IUserRegistration = { username : '' , password : '' , givenName : '' , familyName : '' , email : '' } ; public submitted : boolean = false ; onSignUp ( form ) { this . submitted = true ; if ( form && form . valid ) { UserRegistrationService . signUp ( this . userData ) . then ( ( ) => { this . navCtrl . push ( this . accountConfirmationCodePage ) ; } ) . catch ( ( err ) => { this . showAlert ( 'Sign-up error' , err . message ) ; console . log ( err ) ; } ) ; } } private showAlert ( title , subTitle ) { let alert = this . alertCtrl . create ( { title : title , subTitle : subTitle , buttons : [ { text : 'OK' , handler : ( ) => { console . log ( 'OK clicked' ) ; } } ] } ) ; alert . present ( ) ; } constructor ( public navCtrl , private alertCtrl , private userRegistrationService , private globals ) { } ionViewDidEnter ( ) { Logger . banner ( "Register" ) ; } }