diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/controllers.js b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/controllers.js index ed57b00e9..07f12d773 100644 --- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/controllers.js +++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/controllers.js @@ -24,12 +24,12 @@ angularStrutsApp.controller('HomeController', function ($scope) { $scope.name = "Sunshine"; }); -angularStrutsApp.controller('ApacheProjectsController', function ($scope, $http, DataService) { +angularStrutsApp.controller('ApacheProjectsController', function ($scope, $log, DataService) { this.init = function() { DataService.getProjects().then(function(data) { - $scope.projects = data.data.projectNames; - }, function(data) { - console.log('Could not receive project names.') + $scope.projects = data.projectNames; + }, function() { + $log.error('Could not receive project names.') }); }; diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services.js b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services.js index e3be1de3e..10ec86749 100644 --- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services.js +++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services.js @@ -18,7 +18,7 @@ * specific language governing permissions and limitations * under the License. */ -angularStrutsApp.factory('DataService', ['$http', '$q', function($http, $q) { +angularStrutsApp.factory('DataService', ['$http', '$log', '$q', function($http, $log, $q) { var DataService = { urls : { @@ -32,18 +32,19 @@ angularStrutsApp.factory('DataService', ['$http', '$q', function($http, $q) { } var def = $q.defer(); if(method === 'GET') { - return $http.get(url).success(function(data) { - DataService.data = data; + $http.get(url).success(function(data) { def.resolve(data); - }).error(function() { - def.reject("Failed to get 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() { - def.reject("Failed to post data"); + }).error(function(data, code) { + def.reject(data); + $log.error(data, code); }); } return def.promise;