import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; declare var angular: angular.IAngularStatic; import { downgradeInjectable } from '@angular/upgrade/static'; export interface PhoneData { name: string; snippet: string; images: string[]; } @Injectable() export class Phone { constructor(private http: HttpClient) { } query(): Observable { return this.http.get(`phones/phones.json`); } get(id: string): Observable { return this.http.get(`phones/${id}.json`); } } angular.module('core.phone') .factory('phone', downgradeInjectable(Phone));