Angular 无法读取属性';推动';未定义ngx toastr的定义
在我的应用程序中,我试图集成 作为其中的一部分,我已经初始化了package.json和angular.json。 到目前为止,应用程序仍然有效。但当我初始化Angular 无法读取属性';推动';未定义ngx toastr的定义,angular,typescript,Angular,Typescript,在我的应用程序中,我试图集成 作为其中的一部分,我已经初始化了package.json和angular.json。 到目前为止,应用程序仍然有效。但当我初始化app.module.ts 应用程序模块.ts imports: [ BrowserModule, AppRoutingModule, HttpClientModule, FormsModule, ReactiveFormsModule, ToastrModule.forRoot({
app.module.ts
应用程序模块.ts
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
FormsModule,
ReactiveFormsModule,
ToastrModule.forRoot({
timeOut: 1000,
positionClass: 'toast-bottom-right'
})
],
export class AppModule { }
我得到以下错误
@import must precede all other statements (besides @charset)
WARNING in Entry point 'ngx-toastr' contains deep imports into 'C:/Users/angular-frontend/node_modules/@angular/compiler/src/core'. This is probably not a problem, but may cause the compilation of entry points to be out of order.
ERROR in Cannot read property 'push' of undefined
使用@NgModule decorator装饰您的导入:
import {ToastrModule} from 'ngx-toastr';
@NgModule({
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
FormsModule,
ReactiveFormsModule,
ToastrModule.forRoot({
timeOut: 1000,
positionClass: 'toast-bottom-right'
})
],
})
export class AppModule {}
请参见我已通过
ng update@angular/cli@angular/core——允许脏的
,或者,如第一行所述,确保所有导入都位于页面顶部