我可以在哪里放置ngx-toastr配置文件?

时间:2020-08-11 15:47:41

标签: angular toastr

我是Angular的新手,并开始从事一些现有项目。

它在 package.json 依赖项中有"ngx-toastr": "~10.0.2",我需要更改其一些默认参数。

我目前有什么:

this.toastr.success('Message');

单次通话有效的方法:

  this.toastr.success('Message', null, {
    timeOut: 1000,
    extendedTimeOut: 1
  });

我找不到任何地方解释如何更改默认值。在这里,也没有在我找到的教程中。

很明显没有人需要提及吗?我想念什么?

1 个答案:

答案 0 :(得分:0)

正如MikeOne所指出的,Angular模块配置位于app.module.ts中
以下是他链接中的代码示例,演示了如何执行此操作:

import { BrowserModule } from '@angular/platform-browser';
import {ToastContainerModule, ToastrModule} from 'ngx-toastr';
[...]

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
// Default module configuration can be tweaked here //
    ToastrModule.forRoot({
      timeOut: 10,
      progressBar: true,
      positionClass: 'toast-bottom-right',
    }),
    ToastContainerModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
[...]
相关问题