AIA.service("DataService", function ($http, $q) { var deferred = $q.defer(); this.getJson = function (url) { var deferred = $q.defer(); return $http.get(url) .then(function (response) { // promise is fulfilled //debugger; deferred.resolve(response.data); // promise is returned return deferred.promise; }, function (response) { // the following line rejects the promise deferred.reject(response); // promise is returned return deferred.promise; }) ; }; this.getAnotherJson = function (url1) { var deferred1 = $q.defer(); return $http.get(url1) .then(function (response1) { // promise is fulfilled // debugger; deferred1.resolve(response1.data); // promise is returned return deferred1.promise; }, function (response1) { // the following line rejects the promise deferred1.reject(response1); // promise is returned return deferred1.promise; }) ; }; }); //AIA.factory('DataService', function ($http) { // return { // // 1st function // getJson: function (url) { // debugger; // return $http.get(url).then(function (response) { // alert(response.data); // return response.data; // }); // }, // // 2nd function // getAnotherJson: function (url) { // return $http.get(url).then(function (response) { // alert(response.data); // return response.data; // }); } // }; //})