[英]Unable to display Toast message in Angular 5
嗨,我正在Angular 5中開發Web應用程序。我正在嘗試使用https://www.npmjs.com/package/ngx-toastr在Angular 5中顯示Toast消息。 我已經下載了所需的npm模塊並將CSS復制到資產文件夾。 我也加了
從'ngx-toastr'導入{ToastrModule};
在app.component.ts中。
我正在嘗試將吐司消息顯示為
this.toastr.success('Hello world!','Toastr fun!');
運行解決方案時,出現以下錯誤。
當我運行npm install時,出現以下警告,
請確保您導入ToastrModule
在app.module.ts
import {ToastrModule} from 'ngx-toastr';
在您的組件中,您需要導入提供程序
import { ToastrService } from 'ngx-toastr';
構造函數中的注入器為DI
constructor(public toastr: ToastrService) {}
您可以將其調用為
this.toastr.success(message, 'Success!');
編輯
您需要移至angular6才能使其正常工作。 在here
檢查相關問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.