Angular: Empty Fiddle
http://angularjs.org/
by neilsarkar
HTML
<script src="http://code.angularjs.org/angular-1.0.0rc8.js"></script>
<div ng-controller="MyCtrl">
<input type="file" file-change="setFile">
{{theFile.name}}
</div>
JavaScript
var myApp = angular.module('myApp',[]);
myApp.directive('fileChange', [
function() {
return {
link: function(scope, element, attrs) {
element[0].onchange = function() {
scope[attrs['fileChange']](element[0])
}
}
}
}
])
function MyCtrl($scope, $window) {
$scope.setFile = function(element) {
$scope.$apply(function() {
$scope.theFile = element.files[0];
})
};
}