import { Component } from '@angular/core' ; import { TranslateService } from '@ngx-translate/core' ; import { IonicPage , NavController , ToastController } from 'ionic-angular' ; import { User } from '../../providers/providers' ; import { MainPage } from '../pages' ; @ IonicPage ( ) @ Component ( { selector : 'page-signup' , templateUrl : 'signup.html' } ) export class SignupPage { account : { name : string ; email : string ; password : string ; } = { name : 'Test Human' , email : 'test@example.com' , password : 'test' } ; private signupErrorString : string ; constructor ( public navCtrl , public user , public toastCtrl , public translateService ) { this . translateService . get ( 'SIGNUP_ERROR' ) . subscribe ( ( value ) => { this . signupErrorString = value ; } ) ; } doSignup ( ) { this . user . signup ( this . account ) . subscribe ( ( resp ) => { this . navCtrl . push ( MainPage ) ; } , ( err ) => { this . navCtrl . push ( MainPage ) ; let toast = this . toastCtrl . create ( { message : this . signupErrorString , duration : 3000 , position : 'middle' } ) ; toast . present ( ) ; } ) ; } }