使用ng build
或ng serve
时可以很好地工作,但是将ng build --prod
与空白一起使用时会出错并给出错误
未捕获的错误:StaticInjectorError [t-> t]: StaticInjectorError(平台:核心)[t-> t]: NullInjectorError:没有t的提供者!
带有警告,无效的属性名称“ filter”位于3032:2。 在构建时忽略控制台
这是我的 app.module.ts
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { EasyUIModule } from 'ng-easyui/components/easyui/easyui.module';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { UserComponent } from './pages/user/user.component';
import { HttpClientModule } from '@angular/common/http';
import { CookieService } from 'ngx-cookie-service';
import { MainComponent } from './layout/main/main.component';
import { LoginComponent } from './layout/login/login.component';
import { Router, NavigationEnd } from "@angular/router";
import { CookieService as SessionCookie } from "angular2-cookie/services/cookies.service";
import { JwtHelperService } from '@auth0/angular-jwt';
import { DashboardComponent } from './pages/dashboard/dashboard.component';
import { GlobalService } from "./global.service";
import { UserService } from "./pages/user/user.service";
@NgModule({
bootstrap: [
AppComponent
],
declarations: [
AppComponent,
UserComponent,
MainComponent,
LoginComponent,
DashboardComponent,
],
providers: [SessionCookie, CookieService, JwtHelperService, UserService, GlobalService],
imports: [
FormsModule,
ReactiveFormsModule,
BrowserModule,
BrowserAnimationsModule,
EasyUIModule,
AppRoutingModule,
HttpClientModule,
]
})
export class AppModule {
constructor(
private router: Router,
private global: GlobalService
){
}
}