JavaScriptServices icon indicating copy to clipboard operation
JavaScriptServices copied to clipboard

Wrapping 3rd party library in Angular Service

Open paddyza opened this issue 9 years ago • 1 comments

I am trying to add toastr to my project (https://codeseven.github.io/toastr/)

I have done the following:

  1. Added toastr to package.json. Package was successfully downloaded and added to node_modules directory.
  2. Added "toastr" to webpack.vendor.config.js
  3. Ran "webpack --config webpack.config.vendor.js" successfully.
  4. Added and registered my new ToastrService in app.module.
  5. Imported the ToastrService into the Component I want to call it from.

When I try access a method in ToastrService from the Component, I get an error saying "toastr is not defined". Are there any steps I may have missed? I did a search for "toastr" in vendor.js, and was able to locate the code relating to it.

Thanks, Patrick

paddyza avatar Mar 08 '17 17:03 paddyza

It sounds like some aspect of how you've registered or imported your ToastrService isn't correct. I'd recommend checking with the Toastr maintainers about the correct way to use it with Angular 2.

I'll close this because it doesn't appear to be an issue with code here, but rather is a support request relating to third-party libraries. Hope that's OK!

SteveSandersonMS avatar Mar 09 '17 09:03 SteveSandersonMS