Make addonManager to be service

..so it would be possible to use other services/factories/values when registering addon
This commit is contained in:
Kosta Korenkov 2015-08-03 15:49:07 +03:00
parent 823dc6f1a7
commit 56e91029da
1 changed files with 12 additions and 18 deletions

View File

@ -1,28 +1,22 @@
'use strict'; 'use strict';
angular.module('copayApp.services').provider('addonManager', function (lodash) { angular.module('copayApp.services').service('addonManager', function (lodash) {
var addons = []; var addons = [];
this.registerAddon = function (addonSpec) { this.registerAddon = function (addonSpec) {
addons.push(addonSpec); addons.push(addonSpec);
}; };
this.$get = function() { this.addonMenuItems = function () {
var manager = {};
manager.addonMenuItems = function() {
return lodash.map(addons, function (addonSpec) { return lodash.map(addons, function (addonSpec) {
return addonSpec.menuItem; return addonSpec.menuItem;
}); });
}; };
manager.addonViews = function() { this.addonViews = function () {
return lodash.map(addons, function (addonSpec) { return lodash.map(addons, function (addonSpec) {
return addonSpec.view; return addonSpec.view;
}); });
}; };
return manager;
}
}); });