Skip to content

Instantly share code, notes, and snippets.

@goooooouwa
Created May 13, 2014 06:37
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 goooooouwa/183b9a8e7a2477e94f11 to your computer and use it in GitHub Desktop.
Save goooooouwa/183b9a8e7a2477e94f11 to your computer and use it in GitHub Desktop.
simple file select input directive which watches file selected change
angular.module('file',[])
.directive('file', [function(){
return {
scope: {
file: '='
},
link: function(scope, el, attrs){
el.bind('change', function(event){
var files = event.target.files;
var file = files[0];
scope.file = file || undefined;
scope.$apply();
});
}
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment