Skip to content

Instantly share code, notes, and snippets.

@kitofr
Created September 26, 2013 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitofr/6713719 to your computer and use it in GitHub Desktop.
Save kitofr/6713719 to your computer and use it in GitHub Desktop.
Plunker that "wroks" with file upload directive... this does *NOT* work on my machine, it causes >Error: InvalidStateError: DOM Exception 11 Error: An attempt was made to use an object that is not, or is no longer, usable.
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body>
<div ng-controller="MyCtrl">
<input type="file" upload-files="" />
<p>{{files}}</p>
</div>
</body>
</html>
var myApp = angular.module('myApp',[]);
myApp.directive('uploadFiles',function(){
return {
link:function(scope,el,attrs){
el.bind('change',function(e){
scope.$apply(function(){
scope.setFiles(e.target.files);
});
});
}
};
});
function MyCtrl($scope) {
$scope.files = "";
$scope.setFiles = function(arg){
$scope.files = arg;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment