Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kultpower
committed
Jan 20, 2014
1 parent
ff0af8a
commit bfbe7ef
Showing
2 changed files
with
8 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
'use strict'; | ||
|
||
angular.module('oregamiClientApp') | ||
.service('regionService', ['mySettings', '$http', function regionService($mySettings, $http) { | ||
.service('regionService', ['$http', 'Restangular', | ||
function regionService( $http, Restangular) { | ||
return { | ||
getRegions: function() { | ||
// $http returns a promise, which has a then function, which also returns a promise | ||
var url = $mySettings.apiUri + '/region'; | ||
if (getCookie("customUrl")!=null && getCookie("customUrl").length>1 ) { | ||
url = getCookie("customUrl") + '/region' | ||
} | ||
var promise = $http.get(url).then(function (response) { | ||
// The then function here is an opportunity to modify the response | ||
console.log(url + '->' + response); | ||
// The return value gets picked up by the then in the controller. | ||
return response.data; | ||
}); | ||
// Return the promise to the controller | ||
return promise; | ||
return Restangular.all("region").getList(); | ||
} | ||
} | ||
}]); |