angular实现changeFile上传[方法三] #angular #javascript 发表于 2016-08-27 | 分类于 angular | | 阅读次数 View JSFiddle view.html: 1<input type="file" custom-on-change="uploadFile"> controller.js: 1app.controller('myCtrl', function($scope){ $scope.uploadFile = function(event){ var files = event.target.files; }; }); directive.js: 123456789app.directive('customOnChange', function() { return { restrict: 'A', link: function (scope, element, attrs) { var onChangeHandler = scope.$eval(attrs.customOnChange); element.bind('change', onChangeHandler); } };}); View JSFiddle 参考出处