2017-01-16 18 views
1

我將我的Beta版.21版Angular2項目升級到beta.25.5。我已修復所有錯誤,以便在使用AOT或非AOT時(例如ng服務)沒有錯誤自從Angular2 CLI升級以來,無法解析xyz的所有參數:(?,?)

我現在在運行時在瀏覽器加載時會出現許多服務錯誤,它會影響所有參數服務爲那個文件。

Can't resolve all parameters for *servicename*: (?)  

首先我刪除了我正在使用的桶並檢查了循環依賴。

然後,我將它們全部移到App.module中的Providers數組中,並檢查了所有服務都具有@Injectable()。 只有這樣,才能擺脫錯誤的是使用進樣()方法,如:

import { Injectable, Optional, SkipSelf, Inject } from '@angular/core'; 
import { Subject } from 'rxjs/Subject'; 

export interface SpinnerState { 
    show: boolean; 
} 

@Injectable() 
export class SpinnerService { 
    private spinnerSubject = new Subject<SpinnerState>(); 

    spinnerState = this.spinnerSubject.asObservable(); 

    constructor(@Optional() @SkipSelf() @Inject(SpinnerService) prior: SpinnerService) { 

這種固定的錯誤,但隨後我得到了一個第三方庫此錯誤。我該如何調試以找出問題的根本原因?

感謝

nativeError : Error: Can't resolve all parameters for Logger: (?). at SyntaxError.BaseError [as constructor] (http://localhost:4200/vendor.bundle.js:134335:27) [<r

這是我App.Module的樣子:

providers: [ 
     { 
      provide: AuthHttp, 
      useFactory: authHttpServiceFactory, 
      deps: [Http, RequestOptions], 
     }, 
     [Logger], 
     LoggerService, 
     SpinnerService, 
     DataBreezeService, 
     ProfileService, 
     AuthService, 
     AuthGuardService, 
     CanDeactivateGuardService, 

我也有這一套:

{ 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true 
} 

(如前所述,我項目在升級之前工作正常 - 我在發行說明中看不到任何明顯的內容)。

UPDATE 我一直在評論帶有問題的服務,並從構造函數中刪除params,每次它只是移動到下一個服務 - 即。這裏的高層有什麼問題。現在,我也在組件上發生404錯誤,例如。

enter image description here

我不明白爲什麼 - 例如,在404訂閱組件是非常簡單的:我甚至嘗試添加「的moduleId:‘module.id’」,但並沒有區別:

import { Component } from '@angular/core'; 

@Component({ 
    selector: 'app-subscribe', 
    templateUrl: './subscribe.component.html', 
    styleUrls: ['./subscribe.component.scss'] 
}) 
export class SubscribeComponent { 

    constructor() { } 
} 

GET http://localhost:4200/subscribe.component.html 404(未找到)

+0

Logger的構造函數是怎樣的? –

+0

你爲什麼用數組''Logger'包裝Logger,''? - 應該正常工作,只是好奇 –

+0

WRT最後一個問題 - 這只是一個疏忽 - 我改變了。 – Rodney

回答

0

了它,並通過運行移除所有桶進口和馬上要到公測28.3

npm uninstall -g angular-cli 
npm cache clean 
npm install -g [email protected] 

並且還在項目文件夾中更新到本地28.3(更新angular-cli.json & package.json)。

+0

出於興趣,您爲什麼不升級到RC1?在後續版本中有很多好東西 – Rodney

+0

是的,我回復以防萬一有人需要緊急修復:) –

相關問題