my factory code
.factory('appData', ['connectionManager', function($connectionManager) {
return {
getAppDataItem: function(apiName, params) {
console.log('Getting value...');
$connectionManager.sendRequest({
'apiName': apiName,
'params':{
'@key': "'" + params['@key'] + "'"
}
}).then(function(res){
console.log('Retrieved data ', res.data);
return res.data;
});
}
}
}]);
my service code
var x = appData.getAppDataItem('getItemFromAppData', {
'@key': 'last_emp_id'
});
console.log(x);
I want to assign value returned by .then()
in factory to the var x
in my service. But I am unable to do it. please help me. I am getting value up to .then()
. After that I am unable to pass it to the service.