Skip to content

Instantly share code, notes, and snippets.

@felipekm
Created December 8, 2015 12: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 felipekm/99335e78a795c8923b50 to your computer and use it in GitHub Desktop.
Save felipekm/99335e78a795c8923b50 to your computer and use it in GitHub Desktop.
AngularJS file upload directive
angular.module('').directive('file', function () {
return {
scope: {
file: '='
},
link: function (scope, el, attrs) {
el.bind('change', function (event) {
var file = event.target.files[0];
scope.file = file ? file : undefined;
scope.$apply();
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment