Angular 未处理的承诺拒绝2 RC 5
将angular2升级到rc5后,尝试加载我的应用程序时出现以下错误:Angular 未处理的承诺拒绝2 RC 5,angular,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 NoProvid
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(…)
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()
{
}
}
您是否创建了app.module.ts?当你升级到rc-5时,你需要它。按照下面的说明操作
您配置依赖项注入/提供程序的方式似乎有问题。。。你能给我更多的提示吗?当错误发生时。谢谢看起来您忘记在组件或其rc5错误中添加服务作为提供商,angular没有看到它,请检查git上的开放问题。@ThierryTemplier发生在应用程序“Loading..”屏幕中,我不知道从哪里开始查找,因为此错误不涉及任何组件。您是否尝试添加模块@TommyF我是否需要将bootstrap()方法更改为
platformBrowserDynamic().bootstrapModule(AppModule)代码>和所有参数移动到导入:[]
?
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()
{
}
}