With the library ngx-input-file I insert a field of type files for several images, this works correctly, the problem is when I add the formControlName tag, the option to insert images disappears.
My HTML :
<input-file fileAccept="image/*" fileLimit="10" placeholder="Máx 10 Imagenes" formControlName="imagenes"></input-file>
In the component (in the constructor):
this.crearForm = this.formBuilder.group({
nombre: new FormControl('', [
Validators.required,
Validators.minLength(2),
Validators.maxLength(50),
]),
precio: new FormControl('', [
Validators.required,
Validators.min(1),
Validators.max(1000),
]),
imagenes: new FormControl('', [
Validators.required,
]),
});
I have no problem with any other field, just with that, and I think that it is because it is given the value of ''
and that eliminates the option (I think).
Without the tag:
With the tag:
Any ideas why?
Update 1:
My form a little more detailed.
<form [formGroup]="crearForm" (ngSubmit)="crearSubmit()">
<input mdbInputDirective type="text" formControlName="nombre" class="form-control" [ngClass]="{ 'is-invalid': crearSubmitted && crearF.nombre.errors }" [mdbValidate]="false"/>
<label for="nombre">Nombre</label>
<input mdbInputDirective type="number" formControlName="precio" class="form-control" [ngClass]="{ 'is-invalid': crearSubmitted && crearF.precio.errors }" [mdbValidate]="false"/>
<label for="precio">Precio</label>
<pre>Imagenes Demostrativas</pre>
<input-file fileAccept="image/*" fileLimit="10" placeholder="Máx 10 Imagenes"></input-file>
<button type="button" [disabled]="loading" class="btn btn-primary btn-sm waves-light" (click)="crearSubmit()" mdbWavesEffect>Guardar</button>
</form>