This repository has been archived by the owner on Nov 4, 2021. It is now read-only.
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
1 parent
c13665b
commit a80fa91
Showing
1 changed file
with
10 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,32 @@ | ||
angular.module('app.services', []) | ||
|
||
.service('Survey', ['$q', '$http', function($q, $http){ | ||
.service('Survey', ['$http', function($http){ | ||
|
||
var api_url = 'YOUR_SHEETSU_URL'; | ||
var currentID = 1; | ||
|
||
var ret = { | ||
all: function(){ | ||
var deferred = $q.defer(); | ||
|
||
$http.get(api_url).then(function(resp){ | ||
return $http.get(api_url).then(function(resp){ | ||
if (resp.data.length > 0) currentID = parseInt(resp.data[resp.data.length-1].id); | ||
deferred.resolve(resp.data); | ||
return resp.data; | ||
}); | ||
|
||
return deferred.promise; | ||
}, | ||
}, | ||
add: function(data){ | ||
var deferred = $q.defer(); | ||
|
||
currentID++; | ||
data.id = currentID; | ||
|
||
$http.post(api_url+'/column/val', data).then(function(resp){ | ||
deferred.resolve(resp.data); | ||
return $http.post(api_url, data).then(function(resp){ | ||
return resp.data; | ||
}); | ||
|
||
return deferred.promise; | ||
|
||
} | ||
} | ||
|
||
ret.all(); | ||
|
||
return ret; | ||
|
||
}]); | ||
}]); |
a80fa91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish there was a way to flatten this file down and just download the final file.
a80fa91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OccamsRazorCoder just click the "View" button, switch to "Raw" view and save it. :)