So I have an end-user and they are submitting a form on a global div with a button that opens a popup. Long story short, they fill this form out and submit the HTTP methods with Angular RESTing methods. I'm trying to figure out how I can grab that users current URL from where they access the popup, or submit it from. I want to put that URL in a SQL database to understand where users are finding bugs or where they are clicking this button from (The purpose of the popup is to gain information and recieve feedback) What's the right way of going about this?
$windows.location?
$Location?
$routeparams?
I really need some help. i'll post my client-side angular below, the back-end that takes these requests and puts it in the SQL databases are done by my C# Controller.
(function() {
'use strict';
var commonModule = angular.module('ambassadors.commonModule');
commonModule.service('commonService', ['$http', '$q', function($http, $q) {
this.getSettingsView = function() {
var deferred = $q.defer();
$http.get('/api/settings')
.success(function(response) {
deferred.resolve(response);
})
.error(function() {
deferred.reject();
});
return deferred.promise;
};
this.getUserClaims = function() {
var deferred = $q.defer();
$http.get('/api/profile')
.success(function(response) {
deferred.resolve(response);
})
.error(function(response) {
deferred.reject(response);
});
return deferred.promise;
};
this.submitFeedback = function(feedback, file) {
var deferred = $q.defer();
if (file != null) {
var that = this;
this.uploadFile(file).then(
// Success Handler
function(result) {
// update the scec icon in the controller
feedback.FeedbackUpload = result[0].location;
that.postFeedback(feedback, deferred);
},
// Failure Handler
function() {
$scope.messageInfo = "Error uploading feedback file";
return deferred.reject;
});
} else
this.postFeedback(feedback, deferred);
return deferred.promise;
};
this.postFeedback = function(feedback, deferred) {
$http.post('/api/feedback', feedback)
.success(function() {
deferred.resolve();
})
.error(function() {
deferred.reject();
});
}
this.uploadFile = function(file) {
// As per stackoverflow.com/questions/…
// uncorkedstudios.com/blog/…
var feedbackFileFormData = new FormData();
feedbackFileFormData.append("file", file);
var deferred = $q.defer();
$http.post('/api/feedbackfile', feedbackFileFormData, {
withCredentials: true,
headers: {
'Content-Type': undefined
},
transformRequest: angular.identity
})
.success(function(response) {
deferred.resolve(response);
})
.error(function() {
deferred.reject();
});
return deferred.promise;
};
}]);
})();