{"action":"created","issue":{"url":"https://api.github.com/repos/gtramontina/stripe-angular/issues/6","labels_url":"https://api.github.com/repos/gtramontina/stripe-angular/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/gtramontina/stripe-angular/issues/6/comments","events_url":"https://api.github.com/repos/gtramontina/stripe-angular/issues/6/events","html_url":"https://github.com/gtramontina/stripe-angular/issues/6","id":52183649,"number":6,"title":"TypeError: Cannot read property 'apply' of undefined","user":{"login":"calebfaruki","id":5914427,"avatar_url":"https://avatars.githubusercontent.com/u/5914427?v=3","gravatar_id":"","url":"https://api.github.com/users/calebfaruki","html_url":"https://github.com/calebfaruki","followers_url":"https://api.github.com/users/calebfaruki/followers","following_url":"https://api.github.com/users/calebfaruki/following{/other_user}","gists_url":"https://api.github.com/users/calebfaruki/gists{/gist_id}","starred_url":"https://api.github.com/users/calebfaruki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calebfaruki/subscriptions","organizations_url":"https://api.github.com/users/calebfaruki/orgs","repos_url":"https://api.github.com/users/calebfaruki/repos","events_url":"https://api.github.com/users/calebfaruki/events{/privacy}","received_events_url":"https://api.github.com/users/calebfaruki/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-12-16T23:49:37Z","updated_at":"2015-03-09T05:25:13Z","closed_at":null,"body":"```javascript\r\nangular.module('stripe', []).directive('stripeForm', ['$window',\r\nfunction($window) {\r\n\r\n  var directive = { restrict: 'A' };\r\n  directive.link = function(scope, element, attributes) {\r\n    if(!$window.Stripe){\r\n      throw 'stripeForm is not included in the HTML.';\r\n    }\r\n    var form = angular.element(element);\r\n    form.bind('submit', function() {\r\n      var button = form.find('button');\r\n      button.prop('disabled', true);\r\n\r\n      // can either pass an object or can parse a form with data-stripe attributes\r\n      $window.Stripe.createToken(form[0], function() {\r\n        // after getting token, reenable form\r\n        button.prop('disabled', false);\r\n        console.log(scope[attributes.stripeForm]);console.log(scope);\r\n        var args = arguments;\r\n        scope.$apply(function() {\r\n          scope[attributes.stripeForm].apply(scope, args);\r\n        });\r\n      });\r\n    });\r\n  };\r\n  return directive;\r\n}]);\r\n```\r\n\r\n\r\nHere is the full error: \r\n\r\n    TypeError: Cannot read property 'apply' of undefined\r\n    at http://localhost:8100/lib/stripe-angular/stripe-angular.js:22:39\r\n    at Scope.$eval (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20326:28)\r\n    at Scope.$apply (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20424:23)\r\n    at http://localhost:8100/lib/stripe-angular/stripe-angular.js:21:15\r\n    at Object.e.request.success (https://js.stripe.com/v2/:1:1697)\r\n    at window.(anonymous function) (https://js.stripe.com/v2/:1:10496)\r\n    at https://api.stripe.com/v1/tokens?card[number]=4242424242424242&card[cvc]=12…er_agent=stripe.js%2F4871079&callback=sjsonp1418772119600&_method=POST:1:1\r\n\r\nThis code is exactly the same as what exists in your stripe-angular.js file as far as I can tell. What would cause this issue to happen?\r\n\r\nThere were also a few gaps in the setup of stripe-angular in my project. Not sure if this is an error on my part of if there is something else missing from the docs here."},"comment":{"url":"https://api.github.com/repos/gtramontina/stripe-angular/issues/comments/77802025","html_url":"https://github.com/gtramontina/stripe-angular/issues/6#issuecomment-77802025","issue_url":"https://api.github.com/repos/gtramontina/stripe-angular/issues/6","id":77802025,"user":{"login":"gtramontina","id":374635,"avatar_url":"https://avatars.githubusercontent.com/u/374635?v=3","gravatar_id":"","url":"https://api.github.com/users/gtramontina","html_url":"https://github.com/gtramontina","followers_url":"https://api.github.com/users/gtramontina/followers","following_url":"https://api.github.com/users/gtramontina/following{/other_user}","gists_url":"https://api.github.com/users/gtramontina/gists{/gist_id}","starred_url":"https://api.github.com/users/gtramontina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gtramontina/subscriptions","organizations_url":"https://api.github.com/users/gtramontina/orgs","repos_url":"https://api.github.com/users/gtramontina/repos","events_url":"https://api.github.com/users/gtramontina/events{/privacy}","received_events_url":"https://api.github.com/users/gtramontina/received_events","type":"User","site_admin":false},"created_at":"2015-03-09T05:25:13Z","updated_at":"2015-03-09T05:25:13Z","body":"Ohh I see it now... :grinning: \r\n@seibar your solution seems to be the right one anyway! Mind a pull request?"}}