I have a angular controller which has bunch of functions which share the data between them. The problem is, The data which I return from function 1 is used in function 2 and then data returned in function 2 is used in function 3. My problem is the function 2 an d function 3 executes first and say that the data is not found is there a way where I can schedule the function 1 to execute first.
Following is my code for reference:
$scope.Read = function () {
var get = ServiceName.Read();
getConfig.then(function (d) {
$scope.RID = d.data;
alert($scope.RID);
}, function (error) {
$log.error('Oops! Something went wrong while fetching the application key data.' + error)
})
}
$scope.Read();
Function 2 where I want to use the data:
$scope.getApp = function () {
var sub ={
"RID": $scope.RID
}
var App = ServiceName.getApp(sub);
App.then(function (d) {
$scope.LID = d.data.BUser;
}, function (error) {
$log.error('Opps! Something went wrong in getting appplication defaults');
});
}
$scope.getApp();
Any help would be appreciated!
Thank You!
Best Regards,
Sandeep