In the following angular service, I have:
.service('shareDataService', function() {
var myXi = [];
var myYi = [];
var addXi = function(newObj) {
myXi = newObj;
}
var addYi = function(newObj) {
myYi = newObj;
}
var getPlot = function() {
var a = [];
for (var i = 0; i < myXi.length; i++) {
a.push([myXi[i], myYi[i]]);
}
return a;
}
return {
addXi: addXi,
addYi: addYi,
getPlot: getPlot
};
});
Additionally, there is an angular controller:
.controller('plotController', function($scope, shareDataService) {
$scope.getYo = function() {
return shareDataService.getPlot();
};
$scope.lineChartData = [
$scope.getYo()
];
});
I am trying to pass a value from $scope.getYo to $scope.lineChartData as an array. However, when I call $scope.lineChartData in HTML, nothing is displayed. The desired data structure is as follows:
[
[
[2,0],
[3,1],
[5,4]
]
];
UPDATE :
You can find more detailed information on this issue at . Thank you