Angularjs获得了巨大的JSON文件请求 [英] Angularjs get request for a huge json file

查看:114
本文介绍了Angularjs获得了巨大的JSON文件请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从数据库向用户显示一些数据。这些数据是在JSON文件,并具有pretty规模庞大。 JSON文件的大小是大致围绕15MB。我创建了一个服务,使用的承诺API做一个成功的请求并加载数据,并通过在一个div上NG-重复做它展示给用户。现在,当你理解了页面将显示数据,只有当文件可用,使一个GET请求来获取一个15MB文件需要时间的巨大大写金额。我看到在某些情况下,简单的Firefox加载停止一段时间后该文件。现在我的问题是什么,是做这样的任务的角度方式。

I need to display some data from a database to the user. The data is in a json file and has a pretty huge size. The size of json file is roughly around 15MB. I created a service and used the promise api to make a successful request and load the data and show it to user by doing on ng-repeat on a div. Now as you understand the page will show the data only when the file is available and making a get request to fetch a 15MB file takes enormous amout of time. I see in some cases Firefox simple stops loading the file after some time. Now my question is what is the Angular way of doing such a task.

我想到做这样的事情首先显示来自JSON文件只有几个条目,然后滚动页面由剩余的数据填充剩下的,但我想赢得;吨是可能的,因为当get请求它做,它会先下载完整的文件,然后显示数据?

I am thinking of doing something like first showing just a few entries from json file and then on scrolling the rest of the page will be populated by the remaining data but I guess that won;t be possible because when the get request it made, it will first completely download the file and then display data?

角度提供了一些所谓的NG-斗篷但这只是为避免闪烁。有什么样NG-斗篷的角度,我可以使用?
任何其他的想法或如何处理这样的场景或什么是实现这一??的角方式

Angular provides something called ng-cloak but that's just for flickering avoidance. Is there something like ng-cloak in angular that I can use? Any other Ideas or how to deal with such scenarios or what is the angular way of accomplishing this??

推荐答案

根据您的处理基本上是一个巨大的有效载荷JSON的要求。 FWIW你有两个选择:

Based on your requirements of dealing with essentially a huge JSON payload. FWIW you have two options:


  • 您的服务器支持HTTP / JSON流

创建一个角<一个href=\"https://developer.mozilla.org/en-US/docs/Web/Reference/Events/readystatechange\">onreadystatechange处理程序,并使用流JSON解析器如 oboe.js

create an angular onreadystatechange handler and use a streaming JSON parser like oboe.js

您的服务器不支持HTTP / JSON流

做别人都在暗示,并提供给负载分页操作,这样浏览器就可以在需求块加载它。

Do what everyone else is suggesting and provide a paginated access to that payload so that the browser can load it in chunks on demand.

这篇关于Angularjs获得了巨大的JSON文件请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆