2016-08-12 94 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

回答

相关问题