I'm new to Angular, so maybe I'm asking for the impossible, but anyway, here is my task.
Since our server cannot paginate JSON data, I would like to pass JSON and add it page by page to the controller model. The user does not need to wait for the entire stream to load, so I am updating the view for each X record (classified).
I found oboe.js to parse the JSON stream and added it using the gazebo to my project. (bower install oboe --save).
I want to update the controller model during streaming. I did not use the qq implementation of pomises $ q, because there is only one .resolve (...), and I want several pages of data to be loaded through the stream, so $ digest needs to be called from each page. A recovery service called: / service / tasks / search
I created a factory with a search function that I call from the controller:
'use strict'; angular.module('myStreamingApp') .factory('Stream', function() { return { search: function(schema, scope) { var loaded = 0; var pagesize = 100;
My controller:
'use strict'; angular.module('myStreamingApp') .controller('MyCtrl', function($scope, Stream) { $scope.data = []; Stream.search('tasks', $scope); });
All seams work. After a while, the system slows down and the http call does not end after updating the browser. In addition, the browser (chrome) crashes when too many records are loaded. Perhaps I am mistaken because passing the area to the factory search function is not "correct", and I suspect that calling $ digest in this area gives me problems. Any ideas on this are welcome. Especially if you have an idea for its implementation, where the factory (or service) can return the promise, and I could use
$scope.data = Stream.search('tasks');
in the controller.
json angularjs streaming
Ronald brinkerink
source share