Angular Material Form Groups are very React Like :(
#angular
Material Forms use what appear to be "contexts" with the relationship between the Form Group and Form Field.
This is a very "#react" style approach. It's very non declarative which is unusual for angular. Components have to just know, trust that they are in a form group context.
Better to have the form group as an input to the material form field
https://material.angular.io/components/form-field/overview
I use contexts and tuples on occasion, especially in recursive programming or graph processing, but you really have to be very careful with them and use them in very narrow scopes.
I suppose form groups can be recursively nested. Still when possible, I believe you should use a more declarative approach and I think that explicit binding of form group as an input to each mat-form-field is far better strategy
The result of using a context strategy is that you get runtime errors when you get it wrong. I believe angular scans for and detects these issues at startup so they are raised relatively early but its still usually when you are somewhat removed from the breaking change, which makes it somewhat difficult to diagnose and understand the first time you see it.
If you have to read documentation or implementation code to understand the constraint, then it's not declarative. It's not "angular". It's much more #react.
BTW, this is why react is just... so bad :)
#FrontendDevelopment #Coding #SoftwarePatterns
Comments
Post a Comment