Javascript/angular: Clear Image Select Form Input
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 inform
Solution 1:
clear function should be defined as below
$scope.clear = function () {
angular.element("input[type='file']").val(null);
};
Check the snippet below.
var app = angular.module('myApp', []);
app.controller('myCtrl', ['$scope', function($scope){
$scope.uploadFile = function(){
var file = $scope.myFile;
console.log('file is ' );
console.dir(file);
var uploadUrl = "/fileUpload";
fileUpload.uploadFileToUrl(file, uploadUrl);
};
$scope.clear = function () {
angular.element("input[type='file']").val(null);
};
}]);
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script><scriptsrc="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><bodyng-app = "myApp"><divng-controller = "myCtrl"><inputtype = "file"ng-model = "myFile"file-select="file"/><buttonng-click="clear()">clear</button></div></body>
Post a Comment for "Javascript/angular: Clear Image Select Form Input"