title: How to get a json file in Angular 2 using the Http class?
body: <p>I am trying to get a json file using the Http class in Angular 2. I followed the example on the Angular 2 homepage: <a href="https://angular.io/docs/js/latest/api/http/Http-class.html" rel="nofollow noreferrer">https://angular.io/docs/js/latest/api/http/Http-class.html</a>.
  However, I am getting the error message below. I am using Angular 2.0.0-alpha.37, traceur 0.0.91, systemjs 0.16.11, es6-module-loader 0.16.6 and typescript 1.6.2. Any ideas on what might be wrong here?</p>
  
  <p><strong>app.ts</strong></p>
  
  <pre><code>///&lt;reference path="typings/angular2/angular2.d.ts"/&gt;
  ///&lt;reference path="typings/angular2/http.d.ts"/&gt;
  import {Component, View, bootstrap} from 'angular2/angular2';
  import {Http, HTTP_BINDINGS} from 'angular2/http';
  
  @Component({
    selector: 'myApp',
    viewBindings: [HTTP_BINDINGS]
  })
  @View({
    templateUrl: 'myapp.html'
  })
  class MyComponent {
    data: Object;
    constructor(http: Http) {
      http.get('data.json').toRx().map(res =&gt; res.json()).subscribe(data =&gt; this.data = data);
    }
  }
  bootstrap(MyComponent);
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;script src="../node_modules/angular2/bundles/angular2.dev.js"&gt;&lt;/script&gt;
      &lt;script src="../node_modules/angular2/bundles/http.dev.js"&gt;&lt;/script&gt;
      &lt;script src="../node_modules/traceur/bin/traceur-runtime.js"&gt;&lt;/script&gt;
      &lt;script src="../node_modules/es6-module-loader/dist/es6-module-loader.js"&gt;&lt;/script&gt;
      &lt;script src="../node_modules/systemjs/dist/system.src.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;myApp&gt;&lt;/myApp&gt;
      &lt;script&gt;
        System.import('app');
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Result</strong></p>
  
  <pre><code>EXCEPTION: Error during instantiation of MyComponent!.
  EXCEPTION: Error during instantiation of MyComponent!.
  ORIGINAL EXCEPTION: TypeError: Rx.Subject is not a function
  ORIGINAL STACKTRACE:
  TypeError: Rx.Subject is not a function
      at new EventEmitter (angular2.dev.js:22672)
      at new XHRConnection (http.dev.js:7474)
      at XHRBackend.createConnection (http.dev.js:7519)
      at httpRequest (http.dev.js:7291)
      at Http.get (http.dev.js:7369)
      at new MyComponent (:8080/src/app.js:19)
      at angular2.dev.js:8937
      at Injector._proto._instantiate (angular2.dev.js:28045)
      at Injector._proto._new (angular2.dev.js:27985)
      at InjectorInlineStrategy.protoStrategy.instantiateBinding (angular2.dev.js:27774)
  ERROR CONTEXT:
  _Context
  EXCEPTION: TypeError: Cannot read property 'location' of undefined
  EXCEPTION: TypeError: Cannot read property 'location' of undefined
  STACKTRACE:
  TypeError: Cannot read property 'location' of undefined
      at angular2.dev.js:27298
      at Zone.run (angular2.dev.js:136)
      at Zone.run (angular2.dev.js:16593)
      at zoneBoundFn (angular2.dev.js:109)
      at lib$es6$promise$$internal$$tryCatch (angular2.dev.js:1419)
      at lib$es6$promise$$internal$$invokeCallback (angular2.dev.js:1431)
      at lib$es6$promise$$internal$$publish (angular2.dev.js:1402)
      at angular2.dev.js:187
      at microtask (angular2.dev.js:16619)
      at Zone.run (angular2.dev.js:136)
  EXCEPTION: TypeError: Cannot read property 'hostView' of undefined
  EXCEPTION: TypeError: Cannot read property 'hostView' of undefined
  STACKTRACE:
  TypeError: Cannot read property 'hostView' of undefined
      at zone.run.tick (angular2.dev.js:27331)
      at Zone.run (angular2.dev.js:136)
      at Zone.run (angular2.dev.js:16593)
      at zoneBoundFn (angular2.dev.js:109)
      at lib$es6$promise$$internal$$tryCatch (angular2.dev.js:1419)
      at lib$es6$promise$$internal$$invokeCallback (angular2.dev.js:1431)
      at lib$es6$promise$$internal$$publish (angular2.dev.js:1402)
      at angular2.dev.js:187
      at microtask (angular2.dev.js:16619)
      at Zone.run (angular2.dev.js:136)
  </code></pre>