Please see this Plunker. I have a myApp.common.sharedata
module to share data between two modules myApp.interactive.layout.menu
and myApp.interactive.layout.chart
.
If you click the checkbox in the menu
module, it will call service sharedata.check(key);
to update the shared data.
In common/sharedata/sharedata.service.js
function sharedata.check
. I use sharedata.series = response.data.data;
to update the data from $http, it is not working. The data is not synchronized to module myApp.interactive.layout.menu
and myApp.interactive.layout.chart
. I also tried sharedata.series = angular.copy(response.data.data);
, it is not working too. I have to do
for(var i=0; i<response.data.data.length;i++){
sharedata.series[i] = response.data.data[i];
}
Any suggestions? My ultimate goal is to use $http to initialize the shared data in module myApp.common.sharedata
. Now I'm using the static code. If I use
$http.get("https://reqres.in/api/users")
.then(function(response) {
sharedata.series = (response.data.data);
});
The data does not synchronized to module myApp.interactive.layout.menu
and myApp.interactive.layout.chart
too.