File input management for Angular Material
npm install ngx-material-file-input





This project provides :
* ngx-mat-file-input component, to use inside Angular Material mat-form-field
* a FileValidator with maxContentSize, to limit the file size
* a ByteFormatPipe to format the file size in a human-readable format
For more code samples, have a look at the DEMO SITE
```
npm i ngx-material-file-input
`ts
import { MaterialFileInputModule } from 'ngx-material-file-input';
@NgModule({
imports: [
// the module for this lib
MaterialFileInputModule
]
})
`
#### NGX_MAT_FILE_INPUT_CONFIG token (optional):
Change the unit of the ByteFormat pipe
`ts
export const config: FileInputConfig = {
sizeUnit: 'Octet'
};
// add with module injection
providers: [{ provide: NGX_MAT_FILE_INPUT_CONFIG, useValue: config }];
`
selector:
implements: MatFormFieldControl
Additionnal properties
| Name | Description |
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| _@Input()_ valuePlaceholder: string | Placeholder for file names, empty by default |boolean
| _@Input()_ multiple: | Allows multiple file inputs, false by default |boolean
| _@Input()_ autofilled: | Whether the input is currently in an autofilled state. If property is not present on the control it is assumed to be false. |string
| _@Input()_ accept: | Any value that accept attribute can get. more about "accept" |FileInput
| value: | Form control value |boolean
| empty: | Whether the input is empty (no files) or not |(event?) => void
| clear(): | Removes all files from the input |
Example
`html`
{{ 104857600 | byteFormat }}
_Output:_ 100 MB
| Name | Description | Error structure |
| ---------------------------------------------- | ----------------------------------------------- | ----------------------------------------- |
| maxContentSize(value: number): ValidatorFn | Limit the total file(s) size to the given value | { actualSize: number, maxSize: number }` |
☆ to show support :)
* drop event to add files
* _ideas?_
* https://github.com/dherges/ng-packagr
* Jason Aden - Packaging Angular Libraries https://www.youtube.com/watch?v=QfvwQEJVOig