QTI

qti.vn. Được tạo bởi Blogger.

Thứ Tư, 13 tháng 7, 2016

AngularJs: How to check for changes in file input fields?


No binding support for File Upload control
https://github.com/angular/angular.js/issues/1375
<div ng-controller="form-cntlr">
        <form>
             <button ng-click="selectFile()">Upload Your File</button>
             <input type="file" style="display:none" 
                id="file" name='file' onchange="angular.element(this).scope().fileNameChanged(this)" />
        </form>  
    </div>
instead of
 <input type="file" style="display:none" 
    id="file" name='file' ng-Change="fileNameChanged()" />
can you try
<input type="file" style="display:none" 
    id="file" name='file' onchange="angular.element(this).scope().fileNameChanged()" />
Note: this requires the angular application to always be in debug mode. This will not work in production code if debug mode is disabled.
and in your function changes instead of
$scope.fileNameChanged = function() {
   alert("select file");
}
can you try
$scope.fileNameChanged = function() {
  console.log("select file");
}
Below is one working example of file upload with drag drop file upload may be helpful http://jsfiddle.net/danielzen/utp7j/
Angular File Upload Information
URL for AngularJS File Upload in ASP.Net
http://cgeers.com/2013/05/03/angularjs-file-upload/
AngularJs native multi-file upload with progress with NodeJS
http://jasonturim.wordpress.com/2013/09/12/angularjs-native-multi-file-upload-with-progress/
ngUpload - An AngularJS Service for uploading files using iframe
http://ngmodules.org/modules/ngUpload

0 nhận xét:

Đăng nhận xét