starter.factory('User', 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)), user: function (actionname) { return $resource(formatFilter('{0}ext_erp/Comp/{1}/0/', 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; } }; }); })