Created
September 26, 2013 12:52
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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