I'm new to Angular 2. I've followed some tutorial and create an application and now i'm trying to import and use braintree in my project but it doesn't work.
So far I have done this :
npm install @types/braintree-web
npm install --save braintree-web
And I have tried this code :
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-paymenttest',
templateUrl: '../html/paymenttest.html',
}) export class PaymenttestComponent implements OnInit {
client = require('braintree-web/client');
hostedFields = require('braintree-web/hosted-fields');
ngOnInit() {
this.client.create({
authorization: 'CLIENT_AUTHORIZATION'},
(err, clientInstance) => {
this.hostedFields.create(/* ... */);
});
}
}
But i get there two errors :
ERROR in [...]/paymenttest.component.ts (9,12): Cannot find name 'require'.
ERROR in [...]paymenttest.component.ts (10,18): Cannot find name 'require'.
Maybe I've missed some steps ? Or I should import it differently ... I'm a little lost can someone help me?
add this to your typings.d.ts
declare var require: any;