I read a portion of code about creating a service in angularjs, I don't understand what "this" means in this situation (this.uploadFile = function (files)
)
recipesApp.service('uploadsService', function ($http) {
var code = '';
var fileName = '';
this.uploadFile = function (files) {
var fd = new FormData();
//Take the first selected file
fd.append("image", files[0]);
var promise = $http.post('/uploads/uploadFile.json', fd, {
withCredentials: true,
headers: {'Content-Type': undefined },
transformRequest: angular.identity
}).then(function (response) {
code = response.data.code;
fileName = response.data.fileName;
return{
code: function () {
return code;
},
fileName: function () {
return fileName;
}
};
});
return promise;
};
});