How to integrate third party JavaScript in Angular

Integrate third party JavaScript

I am trying to integrate third party JavaScript which has been provided by my client. I have given the path in angular.json file and the script is generated in script.js file.
But none of the methods in JavaScript are getting triggered.

For example on click of a button ,a drop-down should open up. That onclick method is present in the JavaScript file which is not getting triggered.

 

Answers:

  1. How to integrate third party JavaScript in Angular – wrap your script file into IIFE (Immediately invoke function) and import your script file to the component where you need and use it):
  2. How to integrate third party JavaScript in Angular – Create a declaration file for the javascript and include it in typings.d.ts
  3. You can’t store object in localstorage.. but you can convert into string before storing JSON.stringify

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *