Angular2 directive implementing ControlValueAccessor on component gives error

I am trying to create a custom date directive in angular 2 that works with inline directive [(ngModel)]

.
According to the angular2 docs (and various blogs I have found) I have implemented an interface ControlValueAccessor

that works fine if I put my directive on an element <input />

.

<input name="birthday" my-date [(ngModel)]="model.birthday" />

      

When I place 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 attribute maps a form control to an undefined name attribute

As you can see from the above code, I have already specified the name attribute. So I got stuck with this exception that I couldn't find anything useful. Is this some kind of interface limitation ControlValueAccessor

?

A component other-input

is a 3rd party component that I cannot change anything with. Also I would like to use it on many components (like ionic inputs), not just one. Any suggestions or ideas on how to fix this issue are greatly appreciated!

ps: I am using angular 2.4.0 with typescript

+3


source to share





All Articles