define(["app"], function (app) { app.config(function($provide, config){ $provide.decorator('MMWService', function ($delegate, $rootScope, $filter, $timeout) { $delegate.Modules = {}; $delegate.Methods = {}; var sendToWMMServer = $delegate.sendToWMMServer; $delegate.sendToWMMServer = function(sendData, showLoading){ console.log(sendData.content); var data = {Result: JSON.stringify({Result:'success'})}; if($delegate.Methods[sendData.uri]){ data.Result = JSON.stringify($delegate.Methods[sendData.uri](sendData.content)); $timeout(function(){ sendData.success(data); }); } else { sendToWMMServer(sendData, showLoading); } } return $delegate; }); }); });