app.factory('actfactory', function ($http) {
var myservice = {
result: [],
getdata: function () {
$http.get('api calll !!')
.success(function (response) {
console.log(response.data);
myservice.result.push(response.data);
}).error(function () {
if (window.localStorage.getItem("activity") !== undefined) {
self.results.push(JSON.parse(window.localStorage.getItem("activity")));
}
alert("please check your internet connection for updates !");
});
}
};
this is my controller
app.controller("activity", function ($scope,actfactory) {
$scope.activityresult = actfactory.getdata();
console.log( $scope.activityresult);
});
While doing console.log() in controller in am getting empty object ! and my service is console is returning fine response ?
HOW to get the result in controller of the service