I'm new to angular, and i'm little bit confused via doc's from official site...
I have controller, there i have call of service method:
uploaderService.addImage(files);
and such service:
.service('uploaderService', ['$http', 'settings', function ($http, settings) {
var url = undefined;
var addImage = function(files){
var fd = new FormData();
fd.append("file", files[0]);
$http.post(settings.apiBaseUri + "/files", fd,
{
withCredentials: true,
headers: {'Content-Type': undefined },
transformRequest: angular.identity
})
.success(function (data, status, headers, config) {
url = "temp.jpg";
})
.error(function (err, status) {
console.log('operation failed, status: ' + status);
});
};
var deleteImage = function(){
};
return {
addImage: addImage,
deleteImage: deleteImage
};
how could i wait until post data request if finished, and then pass in url variable location? i try so and so, but something gonna bad, and need help)