mirror of
https://github.com/sismics/docs.git
synced 2025-03-14 00:31:40 +01:00
21 lines
494 B
JavaScript
21 lines
494 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* File upload directive.
|
|
*/
|
|
App.directive('file', function() {
|
|
return {
|
|
restrict: 'E',
|
|
template: '<input type="file" />',
|
|
replace: true,
|
|
require: 'ngModel',
|
|
link: function(scope, element, attr, ctrl) {
|
|
var listener = function() {
|
|
scope.$apply(function() {
|
|
attr.multiple ? ctrl.$setViewValue(element[0].files) : ctrl.$setViewValue(element[0].files[0]);
|
|
});
|
|
}
|
|
element.bind('change', listener);
|
|
}
|
|
}
|
|
}); |