M
M
Max Khimenko2016-07-30 02:42:23
API
Max Khimenko, 2016-07-30 02:42:23

Can't output data from JSON in Angular?

I'm using Wp-rest-api v2 in my Wordpress blog and want to display some content with it in my Angular app!
https://webref.ru/dev/angular-cookbook/json - I try to use this example and nothing comes out. There are no errors in the console, but nothing is displayed.

<!DOCTYPE html>
<html ng-app="countryApp">
<head>
  <meta charset="utf-8">
  <title>Пример извлечения данных JSON в Angular.js</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
  <script>
    var countryApp = angular.module('countryApp', []);
    countryApp.controller('CountryCtrl', function ($scope, $http){
      $http.get('http://mywebsite.me/wp-json/wp/v2/posts').success(function(data) {
        $scope.posts = data;
      });
    });
  </script>
</head>
<body ng-controller="CountryCtrl">
  <h2>Пример извлечения данных JSON в Angular.js</h2 >
  <table class="table table-striped">
    <tr>
      <th>Код</th>
      <th>Страна</th>
      <th>Население</th>
    </tr>
    <tr ng-repeat="post in posts">
      <td>{{posts.content}}</td>
    </tr>
  </table>
</body>
</html>

What is the problem tell me

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question