我正在构建一个角度应用程序,当我在本地计算机上运行时,它可以正常工作。但是在firebase上部署应用程序后会导致错误。
Unhandled Promise rejection: No provider for e! ; Zone: angular ; Task: Promise.then ; Value: Error: No provider for e!
at k (vendor.e0a9c104ecc1b06ef61f.bundle.js:1)
at E (vendor.e0a9c104ecc1b06ef61f.bundle.js:1)
at t._throwOrNull (vendor.e0a9c104ecc1b06ef61f.bundle.js:1)
at t._getByKeyDefault (vendor.e0a9c104ecc1b06ef61f.bundle.js:1)
at t._getByKey (vendor.e0a9c104ecc1b06ef61f.bundle.js:1)
at t.get (vendor.e0a9c104ecc1b06ef61f.bundle.js:1)
at qe (vendor.e0a9c104ecc1b06ef61f.bundle.js:1)
at t.get (vendor.e0a9c104ecc1b06ef61f.bundle.js:1)
at Sn (vendor.e0a9c104ecc1b06ef61f.bundle.js:1)
at kn (vendor.e0a9c104ecc1b06ef61f.bundle.js:1) Error: No provider for e!
at k (https://lottery-management-system.firebaseapp.com/vendor.e0a9c104ecc1b06ef61f.bundle.js:1:4823)
at E (https://lottery-management-system.firebaseapp.com/vendor.e0a9c104ecc1b06ef61f.bundle.js:1:5050)
at t._throwOrNull (https://lottery-management-system.firebaseapp.com/vendor.e0a9c104ecc1b06ef61f.bundle.js:1:72085)
at t._getByKeyDefault (https://lottery-management-system.firebaseapp.com/vendor.e0a9c104ecc1b06ef61f.bundle.js:1:72418)
at t._getByKey (https://lottery-management-system.firebaseapp.com/vendor.e0a9c104ecc1b06ef61f.bundle.js:1:71803)
at t.get (https://lottery-management-system.firebaseapp.com/vendor.e0a9c104ecc1b06ef61f.bundle.js:1:70211)
at qe (https://lottery-management-system.firebaseapp.com/vendor.e0a9c104ecc1b06ef61f.bundle.js:1:22155)
at t.get (https://lottery-management-system.firebaseapp.com/vendor.e0a9c104ecc1b06ef61f.bundle.js:1:120927)
at Sn (https://lottery-management-system.firebaseapp.com/vendor.e0a9c104ecc1b06ef61f.bundle.js:1:28914)
at kn (https://lottery-management-system.firebaseapp.com/vendor.e0a9c104ecc1b06ef61f.bundle.js:1:27420)
我浏览了应用程序,查找了所有正在制作的承诺并对其进行了评论,但仍然给了我错误。
由于代码缩小,很难追踪到底发生了什么。 在代码缩小时,是否有更简单的方法来调试错误?还有什么可能导致这个错误?
感谢您的帮助!
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MdButtonModule, MdCardModule, MdMenuModule, MdToolbarModule,
MdTabsModule, MdIconModule, MdSidenavModule,
MdInputModule, MdCheckboxModule, MdTooltipModule, MdGridListModule } from '@angular/material';
import { AboutComponent } from './about/about.component';
import { HeaderComponent } from './header/header.component';
import { routes } from './app.routes';
import { SettingsComponent } from './settings/settings.component';
import { BookComponent } from './book/book.component';
import { ShiftComponent } from './shift/shift.component';
import { ScanComponent } from './scan/scan.component';
import { Settings } from './settings/settings';
import { SettingsService } from './services/settings.service';
import { Book } from './book/book';
import { BookService } from './services/book.service';
import { ShiftService } from './services/shift.service';
import { Shift } from './shift/shift';
import { ScanService } from './services/scan.service';
import { ScanTicket } from './scan/scan-ticket';
import { AuthService } from './services/auth.service';
import { LoginComponent } from './login/login.component';
import { User } from './user/user';
import { AuthGuard } from './guards/auth.guard';
import { AuthRequestOptions } from './guards/auth-request';
import { RequestOptions } from '@angular/http';
import { AuthErrorHandler } from './guards/auth-error-handler';
import { ErrorHandler } from '@angular/core';
import { HomeComponent } from './home/home.component';
import { AuthInterceptor } from './guards/auth.interceptor';
@NgModule({
declarations: [
AppComponent,
AboutComponent,
HeaderComponent,
SettingsComponent,
BookComponent,
ShiftComponent,
ScanComponent,
LoginComponent,
HomeComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpModule,
HttpClientModule,
FormsModule,
ReactiveFormsModule,
MdButtonModule,
MdCardModule,
MdMenuModule,
MdToolbarModule,
MdIconModule,
MdSidenavModule,
MdTabsModule,
MdInputModule,
MdCheckboxModule,
MdTooltipModule,
MdGridListModule,
routes
],
providers: [User, AuthGuard, AuthService, Settings, SettingsService, BookService, Book, ShiftService, Shift, ScanService, ScanTicket,
// {
// provide: RequestOptions,
// useClass: AuthRequestOptions
// },
{
provide: ErrorHandler,
useClass: AuthErrorHandler
},
{
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
multi: true
}],
bootstrap: [AppComponent]
})
export class AppModule { }
答案 0 :(得分:0)
上述问题是由Angular 4.4.3引起的,感谢@yurzui指出这个问题。该问题与文件Zone.js有关。由于@DeborahK
,我能够通过在构建中取消OnLogin (){
let formData: any = new FormData(form);
console.log(formData.fd.get('upload_for'));
console.log("username:",formData.fd.get('username'));
}
来解决这个问题。
升级到角度5.0.0
后问题出现了问题