Created
May 13, 2014 06:37
-
-
Save goooooouwa/183b9a8e7a2477e94f11 to your computer and use it in GitHub Desktop.
simple file select input directive which watches file selected change
This file contains 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
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