2016-09-05 66 views
1

我這是可以正常使用的Angular2 RC5應用程序,升級到RC6我的應用程序後,正在與消息停止:角2 RC5 => RC6遷移導致噴油器的問題

Error: Can't resolve all parameters for LoginComponent: (?, ?).

我有相當典型Angular2設置,在這裏是LoginComponent代碼,在構造函數中每注射參數具有@Injectable()註釋

import {AuthService} from "../../auth/auth-service"; 

import {ActivatedRoute, Router} from "@angular/router"; 
import {Component, Inject, OnInit} from '@angular/core'; 

@Component({ 
    selector: 'login-component', 
    templateUrl: 'login/login.html', 
    styleUrls: ['login/login.css'] 
}) 
export class LoginComponent { 
    private model = {login: '', password: ''}; 

    constructor(private authService: AuthService, private router: Router) { 
    } 


    protected doLogin(event: Event) { 
     this.authService.login(this.model.login, this.model.password).then(() => { 
      this.router.navigate(['/landing']); 
     }); 
    } 
} 

這裏是應用模塊:

import {NgModule} from '@angular/core'; 
import {HttpModule} from '@angular/http'; 
import {BrowserModule} from '@angular/platform-browser'; 
import {FormsModule} from '@angular/forms'; 

import {AppService} from './app-service' 
import {AuthService} from "./auth/auth-service"; 
import {RouterModule} from '@angular/router'; 
import {AppComponent} from "./component/app-component"; 
import {ChessComponent} from './component/chess/chess-component'; 
import {LoginComponent} from "./component/login/login-component"; 
import {LandingComponent} from "./component/landing/landing-component"; 
import {AuthGuardService} from "./auth/auth-guard-service"; 
import {GuidService} from "./shared/guid-service"; 
import {EchoService} from "./io/echo-service"; 
import {PermissionsService} from "./permissions-service"; 
import { 
    EnumerateSetValuesPipe, EnumerateMapPipe, EnumerateMapKeysPipe, EnumerateMapValuesPipe, 
    EnumerateObjectPipe, EnumerateObjectKeysPipe, EnumerateObjectValuesPipe, 
    NeighbouringValuesPipe 
} from "./shared/pipes"; 

import { TinyComponent } from "./component/tiny/tiny"; 
import {HtmlService} from "./component/docs/html-service"; 
import {DocsComponent} from "./component/docs/docs-component"; 

@NgModule({ 
    imports: [ 
     HttpModule, 
     FormsModule, 
     BrowserModule, 
     RouterModule.forRoot([{ 
      path: '', 
      redirectTo: '/landing', 
      pathMatch: 'full' 
     }, { 
      path: 'login', 
      component: LoginComponent 
     }, { 
      path: 'docs', 
      component: DocsComponent, 
      canActivate: [AuthGuardService] 
     }, { 
      path: 'chess', 
      component: ChessComponent, 
      canActivate: [AuthGuardService] 
     }, { 
      path: 'landing', 
      component: LandingComponent, 
     }]) 
    ], 
    providers: [ 
     AppService, 
     AuthService, 
     GuidService, 
     EchoService, 
     HtmlService, 
     AuthGuardService, 
     PermissionsService 
    ], 
    declarations: [ 
     AppComponent, 
     TinyComponent, 
     ChessComponent, 
     LoginComponent, 
     LandingComponent, 

     EnumerateSetValuesPipe, 
     EnumerateMapPipe, 
     EnumerateMapKeysPipe, 
     EnumerateMapValuesPipe, 
     EnumerateObjectPipe, 
     EnumerateObjectKeysPipe, 
     EnumerateObjectValuesPipe, 
     NeighbouringValuesPipe 
    ], 
    bootstrap: [ 
     AppComponent 
    ] 
}) 
export class AppModule { 
    public constructor() { 

    } 
} 

不知道如何調試這樣的問題......任何想法?

+0

'@NMModule()'是怎麼樣的? –

+0

增加了它,順便說一句我的IDE在吠叫HttpModule說它不能解析符號? – Lu4

+0

找不到任何可疑內容。 –

回答

0

這是一個問題,@Injector被宣佈的方式,不知道它如何工作以前,但我已經宣佈這種方式@Injectable而不是@Injectable()

當您用@Injectable裝飾您的班級時,請將其誤解爲裝飾者。

2

我對我的某個組件有同樣的問題。在另一個使用相同組件的應用程序中,不存在這樣的錯誤。所以它必須與通過模塊聲明或應用的方式有關。

奇怪的是,如果組件的源文件未加載(錯誤的文件路徑),則會出現相同的錯誤。