1
我在Angular2中找到了一些用於DI解釋的fantastic links,但是我仍然無法使它在Safari上工作。在下面的代碼中,它適用於Firefox和Chrome,但我仍然在Safari中獲得Can't resolve all parameters for ApiService: (Http, ?).
。我錯過了什麼嗎?DI在Safari上不工作
import { Injectable } from '@angular/core';
import { Http, Response, RequestOptions, URLSearchParams } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { EmitterService } from '../services/emitter.service';
@Injectable()
export class ApiService {
constructor (
private http: Http,
private window: Window
) {}
}
從我能告訴一切都存在,是否有一個已知的跨瀏覽器兼容性問題,我失蹤了?或者,也許專門爲Safari的polyfill?
- 我已經設置了@NgModules以包含
HttpModule
。
import { HttpModule } from '@angular/http';
你怎麼提供的依賴? –
@GünterZöchbauer截至目前,我有@NgModule({0}進口:[ HttpModule, –
'Http'依賴項導入不是問題,正如你在錯誤信息中看到的,第二個參數'Window'是問題。另見http://stackoverflow.com/questions/34177221/angular2-how-to-inject-window-into-an-angular2-service特別是下面的評論http://stackoverflow.com/a/35003208/217408 –