javascript - Object property not being set but console says otherwise -
I am trying to install a bar verification service using angular. I basically want to call StripeResponse.get () and want to send it back with either error or token that responds with the strip.
My problem is that when I execute this code, if I var a = StripeResponse.get ();
and then log in to a
in the console, I see null
.
If I Console.log (this);
OK before back to this Give Feedback
, I see the following:
object {response: zero, get: function}> Receive: function () {v response: object code: "invalid_number" message: "this card number invalid" parameter looks: "number" type: "card_arthror"
I understand There is a discrepancy between "feedback: nullity" and "reaction: object" in the console log below that is not my code for service / module.
var app = angular Module ('stripe verified', []); App.service ('Stripe Response', Function () {Return: response: blank, Receive: function () {var form = $ ('form [name = "ccForm"]'); Stripe .createtooken (form, $ .proxy (function (position, response) {if (reaction. Panic) {this .response = response.error;}; come back, this is return.response = response.id;}}, this)); return.response; }}}); The createToken
method does not return a promise or
any There is no type of callback mechanism, you should only use angular and create a promise pattern for your service.
app.service ('striperesons', ['$ q', function ($ q)) {return: response: receive: function () {var defered = $ q.defer ( ); // a deffered object var form = $ ('form [name = "ccForm"]'); Stripe.CreateToken (form, function (status, response) {if (response.error) {defered.reject (response; panic); // reject the promise; other; (declared .rod.id); // solve the promise}});) returned. Launched;}}}]);
And you will simply do (pseudocode) when consuming the service:
Stripsations service (). Then (function (id) {// handle success}). Catch (function (error) {// handle failure})
Comments
Post a Comment