无法在 Angular 5 中显示 Toast 消息 [英] Unable to display Toast message in Angular 5
问题描述
我正在 Angular 5 中开发 Web 应用程序.我正在尝试使用
当我运行 npm install 时,我收到以下警告,
有人可以帮我解决这个问题吗?任何帮助,将不胜感激.谢谢你.
确保在 app.module.ts
中导入了 ToastrModule
代码>
import {ToastrModule} from 'ngx-toastr';
在您的组件中,您需要导入提供程序
import { ToastrService } from 'ngx-toastr';
构造函数中的注入器作为 DI
constructor(public toastr: ToastrService) {}
你可以调用它
this.toastr.success(message, '成功!');
编辑
您需要移动到 angular6 才能使其工作.检查相关问题此处
Hi I am developing web application in Angular 5. I am trying to display toast message in Angular 5 using https://www.npmjs.com/package/ngx-toastr. I have downloaded required npm modules and copied css to assets folder. Also I have added
import { ToastrModule } from 'ngx-toastr';
in app.component.ts.
I am trying to display toast message as
this.toastr.success('Hello world!', 'Toastr fun!');
When I run my solution I get below error.
When I run npm install, I get below warnings,
Can someone help me to figure out the issue? Any help would be appreciated. Thank you.
Make sure you imported ToastrModule
in app.module.ts
import {ToastrModule} from 'ngx-toastr';
in your component, you need to import the provider
import { ToastrService } from 'ngx-toastr';
injector in the constructor as DI
constructor(public toastr: ToastrService) {}
And you can invoke it as
this.toastr.success(message, 'Success!');
EDIT
You need to move to angular6 inorder to make it work. Check the related issue here
这篇关于无法在 Angular 5 中显示 Toast 消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!