laurihy / angular-payments

Module that provides AngularJS-directives for formatting, validating and working with payments
560 stars 269 forks source link

Calling the stripe-form directive method from a controller (or another directive) #94

Closed jakeywan closed 7 years ago

jakeywan commented 8 years ago

I'm having trouble calling the stripe-form directive from my controller. The reason I'm doing it like this is that the button I need to use to 'submit' the form is outside of the form element. I've tried a few different things (like calling the stripeForm directive on click of an element, etc.), but it's surprisingly tricky. Any idea how I could implement this?

mr-White commented 8 years ago

I ran into this issue. You have to bind the call back function on local $scope. There is a point in the code where it does something like this: scope[attr.stripeForm]. Therefore, if you bound your callback function to a controller, it will try scope['ControllerName.functionBound'] which breaks... it would have to split the string by period and access the nested function.