Here is the steps to create a singleton service-
  • Import the injectable member using import {Injectable} from '@angular/core';
  • Import the HttpModule, Http and Response members’ as import { HttpModule, Http, Response } from '@angular/http';
  • Add the decorator @Injectable()
  • Export –
    export class UserService {
       constructor(private _http: Http) { }
    }
BY Best Interview Question ON 24 Jun 2020