All of this is in angular.
Without too many boring details, I have an image upload button that doesn't actually upload images. Instead, the 'dummy' form element just passes information on to a different array that shows little preview thumbnails of the image and gives the user the option to delete any they don't want to upload.
All of this is working rather neatly (as neatly as image upload ever works), except for one irritating detail:
The 'dummy' button always displays the number of images last 'uploaded' even though the user might have deleted those images from the actual array of record. The button can also be used multiple times, so it could say '2 files' when in fact there are 8 files. Or 10. Or 0.
I want to empty that input via the controller after adding its contents to the array of record, but I can't figure out how.
I've tried nulling out the model for the input, per an SO answer that is:
vm.addImages=null;
No luck. Still '2 files'.
I've tried rummaging around in the form object itself, again via an SO answer but I don't want to clear the entire form, just this one element.
Here's the relevant $watch from the controller:
$scope.$watch('vm.addImages', function() {
if(vm.addImages.length){
_.each(vm.addImages, function(image){
vm.building.images.push(image);
});
vm.addImages = null; //this is the issue.
}
});
Any ideas?
Thanks.
