AngularJs: How to check for changes in file input fields?
angular . module ( ' app ' , []) . controller ( ' MainCtrl ' , MainCtrl) . directive ( ' fileChange ' , fileChange); function MainCtrl ( $scope ) { $scope . upload = function () { // do something with the file alert ( $scope . file . name ); }; } function fileChange () { return { restrict : ' A ' , require : ' ngModel ' , scope : { fileChange : ' & ' }, link : function link ( scope , element , attrs , ctrl ) { element . on ( ' change ' , onChange); scope . $on ( ' destroy ' , function () { element . off ( ' change ' , onChange); }); function onChange () { ctrl . $setViewValue (element[ 0 ]. files [ 0 ]); scope . fileChange (); } } }; } < div ng-app = " app " ng-controller = " MainCtrl " > < input t