Skip to content

Instantly share code, notes, and snippets.

@harishrathi
Last active July 3, 2019 07:13
Show Gist options
  • Save harishrathi/f2c122ebf7c3e0f35f5f3afede786fd9 to your computer and use it in GitHub Desktop.
Save harishrathi/f2c122ebf7c3e0f35f5f3afede786fd9 to your computer and use it in GitHub Desktop.
angular-file-upload-control
<form [formGroup]="form">
<formly-form [model]="model" [fields]="fields" [form]="form"></formly-form>
</form>
<pre>{{model | json}}</pre>
<pre>invalid: {{form.invalid}}</pre>
<pre>errors: {{form.errors | json}}</pre>
import { FormGroup } from '@angular/forms';
import { FormlyFieldConfig } from '@ngx-formly/core';
public form = new FormGroup({});
public model: any = {};
public fields: FormlyFieldConfig[] = [
{
key: 'file',
type: 'file',
templateOptions: {
label: 'File Name',
placeholder: 'Select File',
accept: 'image/jpeg',
appearance: 'outline',
// required: true // ,
// maxSize: 900
}
},
{
key: 'text',
type: 'input',
templateOptions: {
type: 'text',
appearance: 'outline'
}
},
{
key: 'date',
type: 'datepicker',
templateOptions: {
appearance: 'outline',
label: 'File Date',
placeholder: 'select date',
required: true,
minDate: '2019-01-01',
maxDate: '2019-12-31'
}
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment