I am trying to import this JS library into my Ionic 4 project: 'https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js' to use it in my angular componets. I've been looking all over the web without solution.

I tried to import into my angular.json file but is not working.

"scripts": ["https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js"]

Also I tried to import directly from my index.html but it seems is not able to read it.

Docs link

1 Answers

1
Paresh Gami On Best Solutions

You can try like this

home.page.ts

import { Component } from '@angular/core';
declare var Mercadopago: any;

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {
  constructor() {
    console.log(Mercadopago);
  }
}

index.html

<html>
<body>
  <app-root></app-root>
</body>
<script src="https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js"></script>
</html>