import 'rxjs/add/operator/catch' ; import 'rxjs/add/operator/map' ; import 'rxjs/add/operator/toPromise' ; import { Injectable } from '@angular/core' ; import { Http , Response } from '@angular/http' ; @ Injectable ( ) export class ConfigService { private _config : any ; constructor ( private http ) { } get config ( ) : any { return this . _config ; } set config ( data ) { this . _config = data ; } load ( url ) { return this . http . get ( url ) . map ( ( res ) => res . json ( ) ) . toPromise ( ) . then ( ( data ) => this . config = data ) . catch ( ( err ) => Promise . resolve ( ) ) ; } }