/** * Created by robin on 11/21/15. */ (function () { 'use strict'; angular.module('camotionAdmin') .factory('HelperService', ['HostsService', '$q', function (HostsService, $q) { var HelperService = {}; HelperService.getForeignEntities = function (service, promise) { var defer = $q.defer(); HostsService.getAll({}, promise).then(function (hosts) { var hostsArray = {}; for (var i = 0; i < hosts.Data.length; ++i) { var host = hosts.Data[i]; hostsArray[host.Id] = host; } service.getAllTypes(promise).then(function(types) { var typesArray = {}; for (var i = 0; i < types.Data.length; ++i) { var type = types.Data[i]; typesArray[type.Id] = type; } defer.resolve({ hosts: hostsArray, types: typesArray }); }, defer.reject); }, defer.reject); return defer.promise; }; return HelperService; }]); })();