1
私はhtmlページでデータを取得していません。 home.htmlAngularJS jsonpが私のために働いていない
<!Doctype html>
<html ng-app="myServiceApp">
<head>
<title>Processing $http.jsonp() response in service</title>
</head>
<body>
<div ng-controller="myServiceCtrl">
<h3>Processing $http.jsonp() response in service</h3>
<button ng-click="doJSONPRequest()">Click and make JSONP request</button>
<p>Data Details: {{details}}</p>
<p>Status Code: {{statcode}}</p>
</div>
</body>
</html>
myServiceCtrl.js
var app = angular.module('myServiceApp', []);
app.controller('myServiceCtrl', function ($scope, $http) {
$scope.doJSONPRequest = function() {
var url = "http://public-api.wordpress.com/rest/v1/sites/wtmpeachtest.wordpress.com/posts?callback=JSON_CALLBACK";
$http.jsonp(url)
.success(function (data, status, headers, config) {
$scope.details = data.found;
$scope.statcode = status;
})
.error(function (data, status, headers, config) {
$scope.statcode = status;
});
}
});
あなたのHTMLページ内の任意の ''
通常のhtmlページと同じようにangular.jsファイルを含めるまで、
このページを角度アプリとして実行するには、以下のコードを使用します。
出典
2016-12-02 04:46:06