import { Injectable } from '@angular/core' ; @ Injectable ( ) export class VcfLoaderService { vcards : string ; constructor ( ) { } private handleError ( error ) { console . error ( 'An error occurred' , error ) ; return Promise . reject ( error . message || error ) ; } loadVCFFile ( file ) { let reader = new FileReader ( ) ; reader . readAsText ( file , 'UTF-8' ) ; return new Promise ( ( resolve , reject ) => { reader . onload = ( event ) => { this . vcards = event . target . result ; resolve ( < string > this . vcards ) ; } ; } ) . catch ( this . handleError ) ; } getLoadedContacts ( ) { return new Promise ( ( resolve , reject ) => { resolve ( < string > this . vcards ) ; } ) . catch ( this . handleError ) ; } }