2016-08-12 79 views
3

升級我的angular2後RC5我碰到下面的錯誤嘗試加載我的應用程序時:未處理的承諾拒絕角2 RC 5

zone.js:461 Unhandled Promise rejection: Error: DI Exception 
     at NoProviderError.BaseException [as constructor] (http://localhost:4200/vendor/@angular/core/src/facade/exceptions.js:27:23) 
     at NoProviderError.AbstractProviderError [as constructor] (http://localhost:4200/vendor/@angular/core/src/di/reflective_exceptions.js:43:16) 
     at new NoProviderError (http://localhost:4200/vendor/@angular/core/src/di/reflective_exceptions.js:80:16) 
     at ReflectiveInjector_._throwOrNull (http://localhost:4200/vendor/@angular/core/src/di/reflective_injector.js:786:19) 
     at ReflectiveInjector_._getByKeyDefault (http://localhost:4200/vendor/@angular/core/src/di/reflective_injector.js:814:25) 
     at ReflectiveInjector_._getByKey (http://localhost:4200/vendor/@angular/core/src/di/reflective_injector.js:777:25) 
     at ReflectiveInjector_._getByReflectiveDependency (http://localhost:4200/vendor/@angular/core/src/di/reflective_injector.js:767:21) 
     at ReflectiveInjector_._instantiate (http://localhost:4200/vendor/@angular/core/src/di/reflective_injector.js:665:36) 
     at ReflectiveInjector_._instantiateProvider (http://localhost:4200/vendor/@angular/core/src/di/reflective_injector.js:636:25) 
     at ReflectiveInjector_._new (http://localhost:4200/vendor/@angular/core/src/di/reflective_injector.js:625:21) 
    Evaluating http://localhost:4200/main.js 
    Error loading http://localhost:4200/main.js ; Zone: <root> ; Task: Promise.then ; Value: Error: Error: DI Exception(…)consoleError @ zone.js:461_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426 
zone.js:463 Error: Uncaught (in promise): Error: Error: DI Exception(…) 

我不知道什麼是錯的......

偏偏該應用程序 「中..」 屏幕

main.ts

import {provide,enableProdMode} from '@angular/core'; 
import {provideForms,disableDeprecatedForms} from '@angular/forms'; 
import {bootstrap} from '@angular/platform-browser-dynamic'; 
import { appRouterProviders } from './app.routes'; 
import {RequestOptions,HTTP_PROVIDERS} from '@angular/http'; 
import 'rxjs/add/operator/map'; 
import {AppComponent} from './app.component' 
import {MainMenuComponent} from './main-menu.component' 
import {JwtService} from './services/jwt.service'; 
import {CustomRequestOptions} from "./helpers/CustomRequestOptions"; 
import * as moment from 'moment'; 

bootstrap(AppComponent, [ 
JwtService, 
    HTTP_PROVIDERS, 
    appRouterProviders, 
    provide(RequestOptions, {useClass: CustomRequestOptions}), 
    disableDeprecatedForms(), 
    provideForms() 
]); 

App.component.ts

import {Component,OnInit} from '@angular/core'; 
import { ROUTER_DIRECTIVES,ActivatedRoute,Router,NavigationEnd,Event } from '@angular/router'; 
//Layout components 
import {MainMenuComponent} from './main-menu.component'; 
import {SidebarComponent} from './sidebar.component'; 
import {TopbarComponent} from './topbar.component'; 
import {WorldMenuComponent} from './world-menu.component'; 
//User global service 
import {JwtService} from './services/jwt.service'; 
//Material design 
import {MD_SIDENAV_DIRECTIVES} from '@angular2-material/sidenav'; 
import {MdButton} from '@angular2-material/button'; 
import {Dir} from '@angular2-material/core/rtl/dir'; 
import {MdIconRegistry,MdIcon} from '@angular2-material/icon/icon'; 


@Component({ 
    selector: 'app', 
    templateUrl: 'app/template/master.html', 
    directives: [MainMenuComponent, ROUTER_DIRECTIVES, 
    SidebarComponent, TopbarComponent, ,MD_SIDENAV_DIRECTIVES, WorldMenuComponent, MdIcon,MdButton,Dir 
    ], 
    viewProviders: [MdIconRegistry], 
    styleUrls: ['app/template/css/master.css'], 

}) 


export class AppComponent implements OnInit { 

    constructor(private router: Router, private JwtService:JwtService){ 
    } 

ngOnInit() 
{ 

} 

} 
+0

看來,有一些錯誤配置的依賴注入/供應商你能給更多這方面的暗示的方式......?當發生錯誤時。謝謝! –

+0

看起來你忘了在組件或其rc5錯誤處添加服務作爲提供程序,並且角度沒有看到它,請檢查git上的開放問題。 – Yevgen

+0

@ThierryTemplier發生在應用程序「Loading ..」屏幕上,我不知道從哪裏開始尋找,因爲此錯誤不涉及任何組件 – TheUnreal

回答

相關問題