angularangular2-http

How to use/import http module?


I've been playing with Angular 2 Quickstart.

How can I use/import http module in Angular 2?

I've looked at Angular 2 Todo's.js, but it doesn't use the http module.

I've added "ngHttp": "angular/http", to dependencies in package.json because I've heard Angular 2 is somewhat modular.


Solution

  • In version 37 you need to do this:

    ///<reference path="typings/angular2/http.d.ts"/>    
    import {Http} from "angular2/http";
    

    And run this tsd command:

    tsd install angular2/http