I have a function that is in angular controller.
scope.asyncInit is called at the end of controller. It is a function that inits data for view.
scope.asyncInit = function() {
scope.phoneData;
dsc.In('module-agreements-lists').run('select_agreements_by_value').now('phone').then(function(res) {
scope.phoneData = res.result;
});
};
I should return data from database and asing it to scope.phoneData variable.
The problem is that when i use it like this:
scope.asyncInit = function() {
scope.phoneData;
dsc.In('module-agreements-lists').run('select_agreements_by_value').now('phone').then(function(res) {
scope.phoneData = res.result;
console.log(scope.phoneData);
});
};
It shows the data that are returned from the server in console log but they are not visible outside the dsc.In('module-agreements-lists').run('select_agreements_by_value').now('phone').then(function(res) ....
The console log that's in the code below returns to console log scope.phoneData as undefined.
scope.asyncInit = function() {
scope.phoneData;
dsc.In('module-agreements-lists').run('select_agreements_by_value').now('phone').then(function(res) {
scope.phoneData = res.result;
});
console.log(scope.phoneData);
};
Am i missing something important here? I have no idea why it's not working properly.