starter.factory('Comp', function ($resource, $q, $filter, cfg, formatFilter, global) { global.erp_api = "http://192.168.1.36:13210/api/"; return { sn: $resource(formatFilter('{0}erp/comp/', cfg.api)), comp: function (actionname) { return $resource(formatFilter('{0}ext_erp/Comp/{1}', cfg.api, actionname == undefined ? "" : actionname)) }, dept: function (actionname) { return $resource(formatFilter('{0}ext_erp/Dept/{1}', cfg.api, actionname == undefined ? "" : actionname)) } }; }) .config(function ($httpProvider) { $httpProvider.interceptors.push(function ($q, cfg, global) { return { 'request': function (config) { if (config.url.indexOf("ext_erp") != -1) { config.headers['cid'] = JSON.stringify({"linkid": global.user.compno, "langid": "TW", "phone": global.user.cellphone}); config.headers['sn'] = global.sn; } return config; } }; }); })