gpt4 book ai didi

angular - 未处理的 promise 拒绝 Angular 2 RC 5

转载 作者:太空狗 更新时间:2023-10-29 19:35:27 24 4
gpt4 key购买 nike

将我的 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(…)

我不知道哪里出了问题......

发生在应用程序“正在加载..”屏幕中

主要.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()
]);

应用程序组件.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 时需要它。请按照以下说明操作。

https://angular.io/docs/ts/latest/cookbook/rc4-to-rc5.html

关于angular - 未处理的 promise 拒绝 Angular 2 RC 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38912913/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com