mirror of
https://github.com/apache/struts.git
synced 2026-08-06 07:06:58 +00:00
Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/struts into develop
This commit is contained in:
+4
-4
@@ -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.')
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
+8
-7
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user