var newImageModalHelper ModalHelper src app templates companies add_im

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var newImageModalHelper = ModalHelper('src/app/templates/companies/add_image.html', {}, {
upload: function() {
var model = this.getModel();
return function (files) {
if (files && files.length) {
var file = files[0];
//CompanyFileUpload.uploadFile(file).then(function(data) {
// model.thumbnail_url = data.thumbnail_url;
// model.image = data.image;
// model.name = data.name;
//})
model.thumbnail_url = undefined;
var upload = $upload.upload({
url: '/api/companies/fileupload/',
file: file
}).progress(function (evt) {
model.progress = parseInt(100.0 * evt.loaded / evt.total);
}).success(function (data, status, headers, config) {
model.thumbnail_url = data.thumbnail_url;
model.image = data.image;
model.name = data.name;
}).error(function (data, status, headers, config) {
//model.thumbnail_url = data.thumbnail_url;
//model.image = data.image;
//model.name = data.name;
});
}
};
}
});
$scope.newImage = function() {
return newImageModalHelper.openModal({'company_slug': $stateParams.office_slug}, CompanyOffice.add_image).result.then(function(data) {
$scope.officeImages.images.push(data)
});
};