mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
fixed file upload, styling, boolean/date/output inputs
This commit is contained in:
24
src/app/shared/utils/file-value-accessor.directive.ts
Normal file
24
src/app/shared/utils/file-value-accessor.directive.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {Directive} from '@angular/core';
|
||||
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';
|
||||
|
||||
@Directive({
|
||||
// tslint:disable-next-line:directive-selector
|
||||
selector: 'input[type=file]',
|
||||
// tslint:disable-next-line:no-host-metadata-property
|
||||
host : {
|
||||
'(change)' : 'onChange($event.target.files)',
|
||||
'(blur)': 'onTouched()'
|
||||
},
|
||||
providers: [
|
||||
{ provide: NG_VALUE_ACCESSOR, useExisting: FileValueAccessorDirective, multi: true }
|
||||
]
|
||||
})
|
||||
export class FileValueAccessorDirective implements ControlValueAccessor {
|
||||
value: any;
|
||||
onChange = (_) => { /* empty */ };
|
||||
onTouched = () => { /* empty */};
|
||||
|
||||
writeValue(value) { /* empty */}
|
||||
registerOnChange(fn: any) { this.onChange = fn; }
|
||||
registerOnTouched(fn: any) { this.onTouched = fn; }
|
||||
}
|
Reference in New Issue
Block a user