(function() { window.app.factory("profileSvc", [ "$http", function($http) { var profile = {}; loadProfile(); var svc = { update: update, profile: profile }; return svc; function loadProfile() { $http.post("/Profile/Get") .success(function(data) { angular.copy(data, profile); }); } function update(updatedProfile) { return $http.post("/Profile/Update", updatedProfile) .success(function(data) { angular.copy(data, profile); }); } } ]); })();