0

The console shows that the posts were retrieved successfully, the backend works fine without the angular compatibility.

and its supposed to retrieve post data.

angular.js:12701 XHR finished loading: GET "http://127.0.0.1:8000/auth/posts".

however it shows 5 empty divs like the following

enter image description here

main.js

$http.get('/auth/posts').then(function(data){
    $scope.myposts = data;

});

PostController

   public function getPosts()
    {

        $posts = Post::all();
        return json_encode($posts);
    }

Route

Route::get('auth/posts', 'HomeController@getPosts');

the html file

<div id="mypost" class="col-md-8 panel-default" ng-repeat="post in myposts">
    <div id="eli-style-heading" class="panel-heading"><% post.title %></div>
        <div class="panel-body panel">
            <figure>
                <p> <% post.body %></p>

            </figure>
        </div>
</div>
BARNOWL
  • 3,326
  • 10
  • 44
  • 80

1 Answers1

2

You need to access the data property from the response, I think you need,

$http.get('/auth/posts').then(function(data){
    $scope.myposts = data.data;

});
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396