我对休息和角色技术相对较新 我正在尝试使用 $ http 来使用spring开发的休息服务,但无法使其正常工作。
我的服务类似于Spring's sample test service。我在plunker中尝试了带有角度 $ http 示例的网址,但它失败了:
request failed / -1 error - https://docs.angularjs.org/api/ng/service/$http
这里是角度代码 -
(function(angular) {
'use strict';
angular.module('httpExample', [])
.controller('FetchController', ['$scope', '$http', '$templateCache',
function($scope, $http, $templateCache) {
$scope.method = 'GET';
$scope.url = 'http-hello.html';
$scope.fetch = function() {
$scope.code = null;
$scope.response = null;
$http({method: $scope.method, url: $scope.url, cache: $templateCache}).
then(function(response) {
$scope.status = response.status;
$scope.data = response.data;
}, function(response) {
$scope.data = response.data || "Request failed";
$scope.status = response.status;
});
};
$scope.updateModel = function(method, url) {
$scope.method = method;
$scope.url = url;
};
}]);
})(window.angular);
我错过了什么?任何帮助将不胜感激。