【发布时间】:2018-03-15 15:34:36
【问题描述】:
我在我的角度组件中应用 toasterjs。这是我的代码。
我已经使用代码导入了ToastrService:
import { ToastrService } from 'ngx-toastr';
并在构造函数中注入该服务
constructor(private toastrService: ToastrService) {
}
this.toastrService.success('You are awesome!', 'Success!',)
但它给出了以下错误:
无法解析 ToastrService 的所有参数:(?, [object Object], [object Object], [object Object], [object Object])
当我转到它的定义时,它需要 4 个参数。以下是参数:
success(message?: string, title?: string, override?: Partial<IndividualConfig>): ActiveToast;
我也添加了模块:
imports: [
ToastrModule.forRoot(),
CommonModule,
HttpModule,
FormsModule,
ReactiveFormsModule,
TextboxModuleShared,
DateTimeModuleShared,
DropdownModuleShared
],
那么我如何使用参数,因为我只想显示成功消息?
【问题讨论】:
-
this.toastrService.success('你太棒了!','成功!') not this.toastrService.success('你太棒了!','成功!',)
标签: angular toastr angular-toastr