<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/angular.js/1.6.3/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="siteCtrl">
<p> {{code}}</p><br/>
<p> {{message}} </p><br/>
<ul>
<li ng-repeat="x in results">
{{ x.usercode + " " + x.date +" " + x.position1}}
</li>
</ul>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('siteCtrl', function($scope, $http) {
$http({
method: 'GET',
url: 'http://122.224.254.102:8080/test-service/test/queryRoutes'
}).then(function successCallback(response) {
$scope.code = response.data.code;
$scope.message = response.data.message;
$scope.results = response.data.result;
}, function errorCallback(response) {
$scope.code = "error status" + response.status;
});
});
</script>
</body>
</html>
angularJs1 http get请求代码实例
最新推荐文章于 2021-09-07 23:43:19 发布