未处理的承诺拒绝Angular 2 RC 5

时间:2016-08-12 08:02:54

标签: angular

将我的angular2升级到rc5后,在尝试加载我的应用时出现以下错误:

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 个答案:

没有答案