webui-aria2/js/directives/fileselect.js

22 lines
832 B
JavaScript
Raw Normal View History

2017-07-27 12:31:18 +02:00
// watches changes in the file upload control (input[file]) and
// puts the files selected in an attribute
angular.module("webui.directives.fileselect", []).directive("indeterminate", function () {
return {
// Restrict the directive so it can only be used as an attribute
restrict : "A",
link : function link (scope, elem, attr) {
// Whenever the bound value of the attribute changes we update
// the internal 'indeterminate' flag on the attached dom element
var watcher = scope.$watch(attr.indeterminate, function (value) {
elem[0].indeterminate = value;
});
// Remove the watcher when the directive is destroyed
scope.$on("$destroy", function () {
watcher();
});
}
};
});