I'm trying to create a custom date directive in angular 2 that works with the built in [(ngModel)] directive.
According to the angular2 docs (and various blogs I found), I implemented the ControlValueAccessor interface which works ok if I put my directive on an <input /> element.
<input name="birthday" my-date [(ngModel)]="model.birthday" />
When I put my directive on another component I get the following error:
<other-input name="birthday" [(ngModel)]="model.birthday" my-date></other-input>
More than one custom value accessor matches form control with unspecified name attribute
As it looks like from the code above, I've specified the name attribute already. So I'm stuck with this exception that I could not find anything useful about. Is this some kind of limitation of the ControlValueAccessor interface?
The other-input component is a third party component that I cannot make any change about. Also I would like to use it on many components (also on ionic inputs for example), not just one. Any suggestion or ideas on how to solve this are welcome!
ps: I'm using Angular 2.4.0 with typescript