Repository: struts Updated Branches: refs/heads/master 0fac53954 -> 4286d6a9d
WW-4522 Support latest stable AngularJS version in maven angularjs archetype - Improve data service internal generic _request method Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/215a4f98 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/215a4f98 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/215a4f98 Branch: refs/heads/master Commit: 215a4f9853a65b977b6374eabb4d59c146551adc Parents: 0fac539 Author: Johannes Geppert <[email protected]> Authored: Sun Sep 6 18:14:39 2015 +0200 Committer: Johannes Geppert <[email protected]> Committed: Sun Sep 6 18:14:39 2015 +0200 ---------------------------------------------------------------------- .../src/main/webapp/js/services/DataService.js | 33 ++++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/215a4f98/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services/DataService.js ---------------------------------------------------------------------- diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services/DataService.js b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services/DataService.js index c0034a7..9a8daf1 100644 --- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services/DataService.js +++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services/DataService.js @@ -47,26 +47,25 @@ /** A generic helper method to execute a HTTP request to the backend */ function _request(url, method, model){ + var def = $q.defer(), + req = { + method: method, + url: url + }; + if(!method) { - method = 'GET'; + req.method = 'GET'; } - var def = $q.defer(); - if(method === 'GET') { - $http.get(url).success(function(data) { - def.resolve(data); - }).error(function(data, code) { - def.reject(data); - $log.error(data, code); - }); - } else if(method === 'POST'){ - $http.post(url, model).success(function(data) { - DataService.data = data; - def.resolve(data); - }).error(function(data, code) { - def.reject(data); - $log.error(data, code); - }); + + if(model) { + req.data = model; } + $http(req).success(function(data) { + def.resolve(data); + }).error(function(data, code) { + def.reject(data); + $log.error(data, code); + }); return def.promise; }
