import { Injectable } from "@angular/core" ; import { tap } from 'rxjs/operators' ; import { Observable , of } from "rxjs" ; import { HttpClient } from "@angular/common/http" ; @ Injectable ( ) export class DataService { mydata : any ; constructor ( private http ) { } loadData ( ) { console . log ( "In DataService.loadData()" ) ; if ( this . mydata ) { return of ( this . mydata ) ; } else { return this . http . get < string [ ] > ( "./assets/48MB_DATA.json" ) . pipe ( tap ( data => this . mydata = data ) ) ; } } }