as mentioned above i have an issue getting the data out of the scope, which i set in the scope before in an asynchronous callback function.
Here is some of my Code:
var TransactionCtrl = require("controller/transactions.controller");
var onSuccess = function(_response) {
this.showData = _response;
};
var TransactionsFunction = function() {
//preparing asynchronous call
var transactionCtrlInstance = new TransactionCtrl(onSuccess.bind(this));
//firing asynchronous call
transactionCtrlInstance.getTransactions();
};
TransactionsFunction.prototype.run = function() {
//show this.showData
console.warn(this);
console.warn(this.showData);
};
module.exports = TransactionsFunction;
Important to mention is, that i call the "run" function definitely after the asynchronous call returned, so the data should be applied in the scope.
Does somebody have an explanation or a workaround for this? Does the scope behave different in a callback function even if i bind the scope on it?