import { Component } from '@angular/core' ; import { AlertController , NavController } from 'ionic-angular' ; import { LoginPage } from '../login/login' ; import { SupportPage } from '../support/support' ; import { UserService } from '../../providers/user-service' ; import { User } from '@ionic/cloud-angular' ; import { Camera } from '@ionic-native/camera' ; @ Component ( { selector : 'page-account' , templateUrl : 'account.html' } ) export class AccountPage { birthdate : string ; account : string = "profile" ; base64Image : any = "http://www.gravatar.com/avatar?d=mm&s=140" ; constructor ( public alertCtrl , public nav , public user , public userService , public camera ) { } ngAfterViewInit ( ) { } updatePicture ( ) { let options = { quality : 100 , destinationType : this . camera . DestinationType . DATA_URL , sourceType : this . camera . PictureSourceType . CAMERA , allowEdit : true , encodingType : this . camera . EncodingType . JPEG , targetWidth : 100 , targetHeight : 100 , saveToPhotoAlbum : true , correctOrientation : true , cameraDirection : 0 } ; this . camera . getPicture ( options ) . then ( ( imageData ) => { console . log ( imageData ) ; this . base64Image = 'data:image/jpeg;base64,' + imageData ; } , ( err ) => { } ) ; console . log ( 'Clicked to update picture' ) ; } addDOB ( ) { let alert = this . alertCtrl . create ( { title : 'Add Date of Birth' , buttons : [ 'Cancel' ] } ) ; alert . addInput ( { name : 'birthdate' , value : this . birthdate , placeholder : 'birthdate' , type : 'date' } ) ; alert . addButton ( { text : 'Ok' , handler : ( data ) => { this . user . set ( 'birthdate' , data . birthdate ) ; this . user . save ( ) ; } } ) ; alert . present ( ) ; } changePassword ( ) { console . log ( 'Clicked to change password' ) ; } logout ( ) { this . userService . logout ( ) ; this . nav . setRoot ( LoginPage ) ; } support ( ) { this . nav . push ( SupportPage ) ; } }