Zapobiegaj wycieraniu tablicy po uruchomieniu Angular.js
ou can try something similar
// Untested code
app.factory("chartService", function() {
var chartData;
function saveData(data) {
chartData = data;
}
function getData() {
return chartData;
}
return {
saveData: saveData,
getData: getData
};
});
app.controller("chartCtrl", function($rootScope, $scope, $interval, chartService) {
var data = chartService.getData();
if (data) {
// Navigating back
$scope.data = data;
} else {
// First visit of the session
$scope.data = [[],[],[]];
}
// interval code ...
$scope.$on('$destroy', function() {
chartService.saveData($scope.data);
$interval.cancel(stopChart);
});
});
SAMER SAEID