我可以在哪里放置 ngx-toastr 配置文件?
Where could I put a ngx-toastr config file?
我是 Angular 的新手,开始从事一些现有项目。
它在 package.json 依赖项中有 "ngx-toastr": "~10.0.2"
,我需要更改它的一些默认参数。
我目前拥有的:
this.toastr.success('Message');
单次通话有效的方法:
this.toastr.success('Message', null, {
timeOut: 1000,
extendedTimeOut: 1
});
我找不到任何地方解释如何更改默认值。既不在这里,也不在我找到的教程中。
这么明显没人觉得有必要提一下吗?我错过了什么?
正如 MikeOne 指出的那样,Angular 模块配置位于 app.module.ts
这是他 link 中的代码示例,演示了如何执行此操作:
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 { }
// [...]
我是 Angular 的新手,开始从事一些现有项目。
它在 package.json 依赖项中有 "ngx-toastr": "~10.0.2"
,我需要更改它的一些默认参数。
我目前拥有的:
this.toastr.success('Message');
单次通话有效的方法:
this.toastr.success('Message', null, {
timeOut: 1000,
extendedTimeOut: 1
});
我找不到任何地方解释如何更改默认值。既不在这里,也不在我找到的教程中。
这么明显没人觉得有必要提一下吗?我错过了什么?
正如 MikeOne 指出的那样,Angular 模块配置位于 app.module.ts
这是他 link 中的代码示例,演示了如何执行此操作:
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 { }
// [...]