angular实现changeFile上传[方法一] #angular 发表于 2016-08-27 | 分类于 angular | | 阅读次数 angular实现changeFile上传[方法一]1234<div ng-controller="MyCtrl"> <input type="file" onchange="MyCtrl.prototype.setFile(this)"> {{theFile.name}}</div> 12345678910111213var myApp = angular.module('myApp',[]);function MyCtrl($scope, $window) { $scope.name = 'Superhero'; MyCtrl.prototype.$scope = $scope;}MyCtrl.prototype.setFile = function(element) { var $scope = this.$scope; $scope.$apply(function() { $scope.theFile = element.files[0]; });};