import { Component , OnInit } from '@angular/core' ; import { AlertService } from 'carey-alert' ; import { EmailService } from '../service/email.service' ; @ Component ( { selector : 'app-email-choice' , templateUrl : './email-choice.component.html' , styleUrls : [ './email-choice.component.css' ] } ) export class EmailChoiceComponent implements OnInit { constructor ( private emailService , private alertService ) { } ngOnInit ( ) { } selectGmail ( ) { this . emailService . getGoogleAuthCodeFlowUrl ( ) . subscribe ( ( url ) => this . handleAuthCodeRetrieval ( url ) , ( err ) => this . handleAuthCodeError ( err ) ) ; } private handleAuthCodeRetrieval ( url ) { window . location . assign ( url ) ; } private handleAuthCodeError ( err ) { console . error ( err ) ; this . alertService . error ( "Problem connecting with Gmail!" ) ; } }