I have upload file feature and writing the filename inside input box, but when I upload file next time, the ng-model inside input won't update the filename as newer.How to update ng-model everytime I select new file. Here is the code.
JS:
$scope.setFile = function(element) {
$scope.$apply(function($scope) {
$scope.myFile = element.files[0];
$scope.FileName=$scope.myFile.name;
$scope.FileName = $scope.FileName.replace(/\..+$/, '');
$scope.fileExtension = element.files[0].name.split('.').pop();
console.log($scope.FileName);
console.log($scope.fileExtension);
});
};
HTML code:
<input type="file" name="upload" ng-model="diagram" onchange="angular.element(this).scope().setFile(this)" base-sixty-four-input>
<p>Tags:</p>
<p><input type="text" class="form-control input-sm" ng-model="FileName" ></p>
Any help is appreciated. Thanks