How to use the 3rd party script file in ts component file?

379 views Asked by At

This is the link for the 3rd party script file jsfiddle example link, but in that external file is the 3rd party js script file it having the all functions are self-invoked functions.

How can I declare that function in the ts file?

After declaring the variable in ts file, I need to call the below 3rd party function.

affirm.checkout.open({
     success: function (card_details) {
       console.log('#### calling affirm.checkout.open');
     },
     error: function (error_response) {
       console.log('#### calling affirm.checkout.open Error =======');
     },
     checkout_data: ObjectData;
   });

While am running the application getting the ERROR in src/app/components/checkout/checkout.component.ts(1572,5): error TS2304: Cannot find name 'affirm'.

Please can anyone help me out.

1

There are 1 answers

1
Turzo Ahsan Sami On

add the script to the scripts array in the angular.json file:

        "scripts": [
          "src/script.js"
        ]

after that, you can use it inside typescript file by declaring a variable for it.