Skip to content

Instantly share code, notes, and snippets.

@jfaissolle
Created January 24, 2014 09:40
Show Gist options
  • Save jfaissolle/8594582 to your computer and use it in GitHub Desktop.
Save jfaissolle/8594582 to your computer and use it in GitHub Desktop.
Interactive Linter reproducer
{"undef":true,"unused":true,"curly":true,"indent":2, "browser": true, "jquery":true, "globals":{ "angular": true, "_": true, "jsonpointer": true, "moment": true }}
(function() {
"use stict";
angular.module('components')
.directive('FileSelect', function($timeout) {
return {
templateUrl: '/views/_file-select.html',
replace: true,
restrict: 'A',
transclude: true,
scope: {
onFileSelected: "&"
},
link: function(scope, element) {
var fileInput = angular.element('<input style="display: none;" type="file" accept="image/*; capture=camera" />');
element.parent().append(fileInput);
fileInput.bind('change', function(e){
var files = e.target.files,
file = files.length ? files[0] : null;
if (file) {
scope.onFileSelected({ $file: file });
}
});
scope.selectFile = function() {
$timeout(fileInput.click.bind(fileInput));
};
}
};
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment