1.

How to create a singleton service in Angular 2?

Answer»

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) { }
    }
ALSO Read: How to negotiate a higher SALARY after a job offer


Discussion

No Comment Found