Angular Control Value Attribute with Existing Validation

Is it possible to implement a custom Angular component that acts like ControlValueAccessorit accepts and uses validation directives?

For example, I would like to do something like this:

<input-component [(ngModel)]="someValue" required max="10"></input-component>
<input-component [(ngModel)]="otherValue" email min="10"></input-component>

And the component itself will have the following:

<input type="text" [(ngModel)]="inputValue.prop">
<input type="text" [(ngModel)]="inputValue.otherProp">

Each of the inputs must be checked separately using the validators provided to the component.

But it would have another thing wrapped around it input, so it guarantees its own component.

Is there a way for my component to "accept" validator directives and apply them whenever it wants?

+4
source share
1 answer

4.2.0-beta.0 (2017-05-04)

: min max (# 15813) (81925fa)

0

Source: https://habr.com/ru/post/1676690/


All Articles