import { Component } from '@angular/core' ; import { AlertController , NavController } from 'ionic-angular' ; import { LoginPage } from '../login/login' ; import { UserData } from '../../providers/user-data' ; @ Component ( { templateUrl : 'build/pages/account/account.html' , } ) export class AccountPage { username : string ; constructor ( public alertCtrl , public nav , public userData ) { } ngAfterViewInit ( ) { this . getUsername ( ) ; } updatePicture ( ) { console . log ( 'Clicked to update picture' ) ; } changeUsername ( ) { let alert = this . alertCtrl . create ( { title : 'Change Username' , buttons : [ 'Cancel' ] } ) ; alert . addInput ( { name : 'username' , value : this . username , placeholder : 'username' } ) ; alert . addButton ( { text : 'Ok' , handler : data => { this . userData . setUsername ( data . username ) ; this . getUsername ( ) ; } } ) ; alert . present ( ) ; } getUsername ( ) { this . userData . getUsername ( ) . then ( ( username ) => { this . username = username ; } ) ; } changePassword ( ) { console . log ( 'Clicked to change password' ) ; } logout ( ) { this . userData . logout ( ) ; this . nav . setRoot ( LoginPage ) ; } cleanRemoteFavs ( ) { this . userData . cleanFavorites ( ) ; } }