I need to create a multidimensional array using intervals. I have 5 users who's data grows every 5 seconds. Each user needs array to hold this data that can be accessed for each user later.
currently $rootScope.BHR looks like this:
[1,2,3,4,5,6,7,8,9,10...] <--after 10 secs/ 2 intervals
I want this <--after 10 sec/2 intervals
[1,6..] //key0
[2,7..] //key1
[3,8..] //key2
[4,9..] //key3
[5,10..]//key5
//CODE
var liveDataCtrl = angular.module("xo").controller("liveDataCtrl", ["$scope", "$rootScope", "$http", "$interval", "lodash",
function ($scope, $rootScope, $http, $interval, lodash) {
$rootScope.BHR = [];
function shout() {
$http.get("URL")
.then(function (live) {
$scope.live = live.data;
var key;
for (key in $scope.live) {
console.log($scope.live[key].personnelID, "keys");
var getId = $scope.live[key].personnelID;
$http.get(URL + getId)
.then(function (all) {
var data = all.data[0].HR;
console.log(all.data[0].HR);
$rootScope.BHR.push(data);
})
}
})
}
$interval(shout, 5000);
function hrLive() {
console.log($rootScope.BHR, "SHOUT");
}
$interval(hrLive, 5000);
}]);