Skip to content

Instantly share code, notes, and snippets.

@vladdancer
Created December 2, 2013 09:08
Show Gist options
  • Save vladdancer/7746894 to your computer and use it in GitHub Desktop.
Save vladdancer/7746894 to your computer and use it in GitHub Desktop.
var myApp = angular.module('myApp', []);
var baseService = function () {
this._state = {};
};
baseService.prototype.getState = function () {
return this._state;
};
baseService.prototype.setState = function (state) {
this._state = state;
};
var chartService = function () {
this._seriesParam = {};
};
chartService.prototype = Object.create(baseService.prototype);
chartService.prototype.getSeriesParam = function () {
return this._seriesParam;
};
chartService.prototype.setSeriesParam = function (seriesParam) {
this._seriesParam = seriesParam;
};
myApp.service('baseService', baseService);
myApp.service('chartService', chartService);
function MyCtrl($scope, chartService) {
var state = {
foo: 'bar'
},
seriesParam = {
baz: 'spam'
};
chartService.setState(state);
$scope.state = chartService.getState();
chartService.setSeriesParam(seriesParam);
$scope.seriesParam = chartService.getSeriesParam();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment