Aus irgendeinem Grund möchte ich nicht Konstruktor (private http: Http) DI verwenden.Wie erstellt man eine Http-Instanz ohne Konstruktor DI?
bei https://angular.io/docs/ts/latest/api/http/index/Http-class.html Sah
und versuchte
const injector = ReflectiveInjector.resolveAndCreate([
BaseRequestOptions,
XHRConnection,
{
provide: Http,
useFactory: (backend, defaultOptions) => new Http(backend, defaultOptions),
deps: [XHRConnection, BaseRequestOptions]
}
]);
this.http = injector.get(Http);
Fehler sagt
ORIGINAL AUSNAHME: Alle Parameter für 'XHRConnection' nicht auflösen (?,?,?). Stellen Sie sicher, dass alle Parameter mit Inject versehen sind oder gültige Typ-Annotationen haben und dass "XHRConnection" mit Injectible dekoriert ist.
HTTP_PROVIDERS ist jetzt veraltet. Hast du ein Beispiel für RC.5 +? –