I have the following module :
angular.module('project.itemServices', ['project.cacheFactory', 'project.dataProvider'])
.run(function() {
ISvc = new function () {
this.endpoint = '';
this.name = 'foo';
this.items = {};
this.clean = function () {
cacheFactory.clear(this.name);
items = {};
};
this._store = null;
this.populate = function () {
cacheFactory.look('fetch', this.endpoint, this.name).then(function (data) {
this._store(data);
})
};
};
}
)
.service('catListSvc', function()
{
this.prototype = ISvc.prototype;
})
.run(function(catListSvc)
{
console.log(catListSvc.name);
});
I want all my services in this module to inherit from the ISvc object, and then implement it's own _store
method, this service is intended for sharing data between controllers.
I don't know how to do this, when trying to console.log(catListSvc.name)
, undefined
comes up.
I tried several things eg. Objects.create(ISvc.prototype)
, but doesn't work.
Any idea on how to achieve this?