Angular 2 multiple custom value accessor

Rafael Andrade picture Rafael Andrade · Jun 5, 2017 · Viewed 10.5k times · Source

I am creating an application using angular2.

I need to get a Date from user input using a calendar popover, but I need to put a mask on user input to stay in this format dd-mm-YYYY when he is typing.

I am using two different modules that I got from web ng-bootstrap and angular2-text-mark

<input [textMask]="{mask: mask}" type="text" class="form-control" placeholder="yyyy-mm-dd"
         name="dp" [(ngModel)]="date" ngbDatepicker #d="ngbDatepicker">

When I use textMask and ngbDatepicker on same tag I get this error

ERROR: More than one custom value accessor matches form control with unspecified name attribute.

Is there a way to do this kind of things ?

Thanks

Answer

Akshay picture Akshay · Dec 25, 2018

I was facing the same problem. I have used "ngx-datepicker with mask".I removed ngModel from the input and it's working absolutely fine.