ngModel does not work with datepicker. Angular

0

I am new at Angular and I have encountered this problem. NgModel does not work when I use the datepicker class in the input. Any solution? or what am I doing wrong?

<div class="input-field  col s12 m6 l6 xl6">
     <input id="fecha_inicio" type="text" class="datepicker" formControlName="fecha_inicio" [(ngModel)]="ciclo.fecha_inicio">
           <label for="fecha_inicio">Fecha inicio</label>
           <div *ngIf="formCiclo.controls.fecha_inicio.errors?.required && (formCiclo.controls.fecha_inicio?.touched || submitted)" class="error">
                            El fecha inicio es requerida
           </div>
</div>
    
asked by Alejo 14.02.2018 в 10:26
source

1 answer

0

The $ scope with ng-model , does not interpret the value you select in the datepicker and to collect its value, it must be picked up by id, as follows :

$("#fecha_inicio").val()

And if you want to assign a value:

$("#fecha_inicio").val("21/02/2018")
    
answered by 21.02.2018 / 22:32
source