Reputation: 1030
I am trying to add toastr.js in my angular component
by toasts.js placed in ../../../../../scripts/thirdparty/toastr.js
but when i am trying to import it just line this
import * as toastr from 'toastr';
after installing npm install "@type/toastr" still it is not including.
Upvotes: 0
Views: 878
Reputation: 241
there is an ngx-toastr
package you can use: https://www.npmjs.com/package/ngx-toastr
run npm install --save ngx-toastr
Then add the toastr.css in your .angular-cli.json
file in the styles section like
"styles": [
"../node_modules/ngx-toastr/toastr.css",
"styles.scss"
]
Import the ToastrModule
in your module, where you want to use it like this:
ToastrModule.forRoot({
positionClass: 'toast-bottom-right',
progressBar: true
})
After this setup you can import the ToastrService
in your component
import { ToastrService } from 'ngx-toastr';
inject it in the constructor
constructor(private toastrService: ToastrService){}
and use it
this.toastrService.error(message);
Upvotes: 2