AIA.factory('LabExerciseService', function ($http, $q,$rootScope) { return { saveLabExerciseAttempt: function (labExercieObj) { var deferred = $q.defer(); $http.post('/API/api/LabExercise', JSON.stringify(labExercieObj), { headers: { 'Content-Type': 'application/json' } }) //$http.post('/API/api/LabExercise', JSON.stringify(labExercieObj, userId, labExerciseIdentifier, LastQuestion, TotalQuestions), { // headers: { // 'Content-Type': 'application/json' // } //}) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $rootScope.isVisibleLogin = true; $rootScope.errorMessage = data; $("#messageModal").modal('show'); }); return deferred.promise; }, GetLabExercise: function (labExerciseInfo) { var deferred = $q.defer(); $http({ url: "/API/api/LabExercise", method: "GET", params: {userId:1, labExerciseIdentifier:'di'} }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); $rootScope.isVisibleLogin = true; $rootScope.errorMessage = data; $("#messageModal").modal('show'); }); return deferred.promise; }, } })