i want access array held in service file (chart-serv.js), service file return-serv.js. how call dependent file in double braces [ ], line 1?
return-serv.js
var app = angular.module('starter.return-serv', ['starter.chart-serv']) app.factory("returndata", function() { return { alldata: function() { var data = starter.chart - serv.chartpricesupto6hours; return data } } }); chart-serv.js
var app = angular.module('starter.chart-serv', []) var chartpricesupto6hours = { "10": { "1": 95, "2": 125, "3": 155, "4": 185, "5": 215, "6": 245 }, "20": { "1": 105, "2": 135, "3": 165, "4": 195, "5": 225, "6": 255 } }; the part i'm not sure of alldata function data variable. should call access other file?
you can create service in chartserv.js pass object factory in returnserv.js injecting service factory.
chartserv.js:
var app = angular.module('chartserv', []); app.service('fromservicetofactory', function(){ var chartpricesupto6hours = { "10": { "1": 95, "2": 125, "3": 155, "4": 185, "5": 215, "6": 245 }, "20": { "1": 105, "2": 135, "3": 165, "4": 195, "5": 225, "6": 255 } }; return {chartpricesupto6hours: chartpricesupto6hours}; }); returnserv.js:
var app = angular.module('returnserv', []); app.factory("returndata", function(fromservicetofactory) { return { alldata: function() { var valuefromservice = fromservicetofactory.chartpricesupto6hours; return valuefromservice; } } });
Comments
Post a Comment