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

I am new to angular. I am trying to read the uploaded file path from HTML ‘file’ field whenever a ‘change’ happens on this field. If i use ‘onChange’ it works but when i use it angular way using ‘ng-change’ it doesn’t work.

<script>
   var DemoModule = angular.module("Demo",[]);
   DemoModule .controller("form-cntlr",function($scope){
   $scope.selectFile = function()
   {
        $("#file").click();
   }
   $scope.fileNameChaged = function()
   {
        alert("select file");
   }
});
</script>

<div ng-controller="form-cntlr">
    <form>
         <button ng-click="selectFile()">Upload Your File</button>
         <input type="file" style="display:none" 
                          id="file" name="file" ng-Change="fileNameChaged()"/>
    </form>  
</div>

fileNameChaged() is never calling. Firebug also doesn’t show any error.

15 Answers
15

Leave a Comment