简体   繁体   English

根据请求将数据块从Laravel API顺序发送到Angular

[英]Sending chunks of data sequentially on request from a Laravel api to Angular

I am trying to show comments on my frontend so that they are displayed like facebook comments. 我试图在前端显示评论,以便像Facebook的评论一样显示它们。 Initially you see only few comments and then on scroll you get more comments displayed. 最初,您只看到很少的注释,然后在滚动时显示更多的注释。 I am using Laravel as a backend and Angular for frontend. 我使用Laravel作为后端,使用Angular作为前端。
What I am wondering is how to send from the frontend request for next chunk of data until all of the comments are displayed and make it in Laravel to perform queries for the next chunk at the request? 我想知道的是如何从前端请求发送下一个数据块,直到显示所有注释,并使其在Laravel中对请求中的下一个块执行查询?

Paginate the data on the server and when the user gets on the page, he/she will see only 10 comments for example, but when he/she clicks on the view 10 more comments, show the next page of comments, which are stored as chunks of 10 inside the Paginator object. 对服务器上的数据进行分页,当用户进入页面时,例如,他/她将仅看到10条评论,但是当他/她单击视图时,另外10条评论,则显示下一页评论,其存储为Paginator对象中的10个块。

The same idea would apply if you wanna display the comments on scroll down. 如果您想向下滚动显示注释,则同样的想法也适用。

Build a custom JSON response so you can easily work with it on the front end. 构建自定义JSON响应,以便您可以轻松地在前端使用它。

Check out the Laravel Paginator API: 查看Laravel Paginator API:

https://laravel.com/api/5.2/Illuminate/Pagination/Paginator.html https://laravel.com/api/5.2/Illuminate/Pagination/Paginator.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM