The examples given by the angular team only show how to inject Http for typescript.
https://angular.io/docs/js/latest/api/http/Http-class.html
What's the JS equivalent of this:
import {Http, HTTP_PROVIDERS} from 'angular2/http';
and this:
constructor(http: Http) { }
Assuming you're at alpha 49 or newer (you should be at least at beta.0) and you're using the UMD bundles the correct answer is to use ng.http.Http and ng.http.HTTP_PROVIDERS
var App = ng.core.
Class({
constructor: [ng.http.Http, function(http) {
/* Do something with http */
}]
});
document.addEventListener('DOMContentLoaded', function() {
ng.platform.browser.bootstrap(App, [ng.http.HTTP_PROVIDERS]);
});
Here's a plnkr with a working example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With