I used this solution:
The way to load external scripts
private loadExternalScript(scriptUrl: string) { return new Promise((resolve, reject) => { const scriptElement = document.createElement('script') scriptElement.src = scriptUrl scriptElement.onload = resolve document.body.appendChild(scriptElement) })
Component Code
ngAfterViewInit(): void { this.loadExternalScript("https://www.paypalobjects.com/api/checkout.js").then(() => { paypal.Button.render({ env: 'sandbox', client: { production: '', sandbox: '' }, commit: true, payment: function (data, actions) { return actions.payment.create({ payment: { transactions: [ { amount: { total: '1.00', currency: 'USD' } } ] } }) }, onAuthorize: function(data, actions) { return actions.payment.execute().then(function(payment) {
Credit
Andrew Audrey answers here: script tag in angular2 template when loading dom template
source share