Reputation: 14590
I have a third party JavaScript library (not Angular) and I would like to use its methods/objects from Angular.
I know I can place a <script type="text/javascript">
into an angular HTML view and use those methods there but that's really ugly.
How else could this be done?
Upvotes: 9
Views: 20670
Reputation: 14590
Oh well, I found it, just attach to the $window
and you are done.
As written here: https://developers.braintreepayments.com/javascript+node/sdk/client/setup
"The SDK will appear as braintree on the global window object."
So from your controller (for example) you can simply use $window.braintree
and you got everything you need from Braintree client library.
To load the Dropin you can simply use this:
angular.module('app').controller('YourController', ['$scope', '$window',
function ($scope, $window) {
$window.braintree.setup('CLIENTTOKEN', 'dropin', {
container: 'dropin'
});
}
]);
Upvotes: 10
Reputation: 11755
Include it before Angular and you should be fine
<script type="text/javascript" src="braintree.js">
<script type="text/javascript" src="angular.js">
Using it with angular should not be a problem.
Can you create a Plunker or JSFiddle of a simple problem?
Sample answer of how to use the two together: Encrypting credit card details using AngularJS in Braintree
Upvotes: 5