Am having a factory which makes multiple API calls which are bind to single promise, when I return the promise to my controller am not able to get the data from the object returned by a function in the controller.
Code:
Factory:
app.factory('factory1',function($http,$q){
var formData = {}
var URL = "/xxx/"
var dataToPass = {}
formData.getData = function()
{
var data1 = $http.get(URL+'api1/')
var data2 = $http.get(URL+'api2/')
return $q.all({'data1':data1,'data2':data2})
}
return formData
});
Controller:
app.controller('controller1', function($scope, factory1) {
$scope.uacForm =factory1.getData().then(function(data, status, headers, config)
{
console.log(data['data2'])
},
function(data, status, headers, config)
{
alert("Error")
})
console.log($scope.uacForm)
});
Am not able to get the data from $scope.uacForm object.