WW-4522 Support latest stable AngularJS version in maven angularjs archetype
- Refactor the DataService to only expose the callable members Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d0a25d68 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d0a25d68 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d0a25d68 Branch: refs/heads/master Commit: d0a25d688aedee99d31f06e94fc4fac6fad4227c Parents: 55e10bc Author: Johannes Geppert <[email protected]> Authored: Fri Jul 10 17:37:10 2015 +0200 Committer: Johannes Geppert <[email protected]> Committed: Fri Jul 10 17:37:10 2015 +0200 ---------------------------------------------------------------------- .../src/main/webapp/js/services/DataService.js | 28 +++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/d0a25d68/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 d2612a4..3f9e308 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 @@ -27,13 +27,26 @@ function DataService($http, $log, $q) { + /** Object to manage all backend URL's */ + var urls = { + projects : "data/projects" + }; + + /** The DataService with all public methods */ var DataService = { - urls : { - projects : "data/projects" - } + getProjects: getProjects }; - DataService._request = function(url, method, model){ + return DataService; + + /** Get all projects */ + function getProjects() { + return _request(urls.projects); + } + + + /** A generic helper method to execute a HTTP request to the backend */ + function _request(url, method, model){ if(!method) { method = 'GET'; } @@ -55,13 +68,8 @@ }); } return def.promise; - }; + } - DataService.getProjects = function () { - return this._request(this.urls.projects); - }; - - return DataService; } })(); \ No newline at end of file
