Javascript 加载index.html页面后返回REST API结果
我正在从AngularJS中的RESTAPI获取数据。RESTAPI会在index.html已经加载后返回结果。它不再显示RESTAPI结果 这是我的密码:Javascript 加载index.html页面后返回REST API结果,javascript,angularjs,api,rest,Javascript,Angularjs,Api,Rest,我正在从AngularJS中的RESTAPI获取数据。RESTAPI会在index.html已经加载后返回结果。它不再显示RESTAPI结果 这是我的密码: <!doctype html> <html ng-app="demo"> <head> <title>Hello AngularJS</title> <script src="https://ajax.go
<!doctype html>
<html ng-app="demo">
<head>
<title>Hello AngularJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script src="hello.js"></script>
</head>
<body>
<div ng-controller="Hello">
<p>The content is {{greeting}}</p>
</div>
</body>
</html>
angular.module('demo', [])
.controller('Hello', function($scope, $http) {
$http.get('https://example.com/api/v1/search/searchByDesc?searchType=space_name&searchValue=MLX800').
then(function(response) {
$scope.greeting = response.data;
});
});
你好,安格拉斯
内容是{{问候}
angular.module('demo',[])
.controller('Hello',函数($scope,$http){
$http.get('https://example.com/api/v1/search/searchByDesc?searchType=space_name&searchValue=MLX800').
然后(功能(响应){
$scope.greeting=response.data;
});
});
在调试器中,我可以看到RESTAPI返回结果
如何在浏览器上显示结果
谢谢
R您的api端点不工作
angular.module('demo',[])
.controller('Hello',函数($scope,$http){
$http.get('https://jsonplaceholder.typicode.com/todos/1,然后(函数(响应){
$scope.greeting=response.data;
console.log(response.data)
});
})
你好,安格拉斯
内容是{{问候}
RESTAPI在31秒后返回一个JSON对象。奇怪的是它没有显示在控制台上。但是我可以在调试器中看到200HTTP响应和结果。你能分享你使用的api端点吗?这一个“没有*返回任何json对象”