Created
December 2, 2013 09:08
-
-
Save vladdancer/7746894 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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