DEV Community

loading...

Discussion on: Angular - How many components is too many components?

Collapse
antjanus profile image
Antonin Januska

Oh yeah! Absolutely. But that's when I'd split it based on functionality. Conditionals usually indicate that you're trying to force one thing to fulfill the role of many.

You can also invert the validation and have the parent be responsible (just like you mentioned).

In Angular, you could just do:

<MyInputComponent
(validate)="validateInput($event)"
[isValid]="isInputValid">
</MyInputComponent>

On change, the input component would emit the change for the validateInput to run and the parent component will then let the input know if it's valid or not. :)