I have the following constant :
const getActionsList = {
listActions: [
'$http',
'$route',
'$q',
'$location',
function($http, $route, $q, $location) {
const id = $route.current.params.id;
const deferred = $q.defer();
$http.get('/test/' + id).then(
function(result) {
if (result.data.length > 0) {
deferred.resolve(result.data);
} else {
var urlRedirect = '/';
$location.url(urlRedirect).replace();
}
},
function(result) {
deferred.reject(result);
}
);
return deferred.promise;
}
]
};
the function that is in getActionsList must return a value.
and I would like when I call it in another function that it returns a value rather than a function
var menu = function() {
return {
mediaType: function() {
return getActionsList[4];//should return a value rather than a function
}
};
};
how to get getActionsList [4] to return a value ?