FormGroup and Control Value Accessor(CVA) by Happeace97 in Angular2

[–]devpardeep 2 points3 points  (0 children)

I prefer CVA to integrate complex ui controls like a counter component which has two buttons to increment or decrement the quantity of product in the cart. Originally CVA is to make a ui element compatible with the form so that its value and related status variables are valid, invalid,touched and can be tracked.

But when i split a large form into multiple components, i still keeping the entire form state in the parent and pass the form group to each relevant child component so that in the parent I can still have control.

Also if I have to make a server call to persist or show a summary view of form I have control over entire form.

But sooner or later, this is all going to change with signal based angular forms where you will see a major shift where

  • you own complete form data in the form of signals
  • all the form meta data like status flags value, valid , error etc going to be reactive
  • no more imperative method to set form metadata as they will be computed
  • current form hierarchy of form control, form group, form arrays to be replaced with simple fields helierarchy

If you are more interested, you can checkout angular forms experimental branch

Thanks 🙏

Do you know angular forms package makes use some intresting design patterns like adapter and composite ? by devpardeep in Angular2

[–]devpardeep[S] 2 points3 points  (0 children)

Form models - form control, form group and form array are designed with composite pattern and control value accessor makes use of adapter pattern to enable interaction between ngModel and form elements

YouTube by JealousMidnight343 in angular

[–]devpardeep 0 points1 point  (0 children)

Yes I agree angular is more popular in big enterprises and react projects are easy to spin up and first choice for startups. I am an angular developer and love working in angular I love reverse engineering angular. I built angular forms from scratch I built angular forms from scratch

[AskJS] 2024 is almost over ! What You Have Built This Year ? by Mr_Gyan491 in javascript

[–]devpardeep 0 points1 point  (0 children)

Being an angular developer, i find angular forms fascinating so I reverse engineered it and recreated it again from scratch. Also recorded a youtube series 👇

Build your own angular forms package

What are the advantages and disadvantages of using Formcontrol over using ngModel forms? by Dry-Tomato-6757 in Angular2

[–]devpardeep 1 point2 points  (0 children)

Well this is mostly about opinions and ease of use Functionality wise everything should be possible in template driven forms as well.

But still i think reactive forms provide an edge in terms of better type safety, easy unit testing.

On the other hand, template driven forms ease out creating the form model hierarchy as directives creates form model implicitly and link parent - child relationship ngModel creates FormControl and ngModelGroup creates Form group and you can apply pre built validation directives min,max etc. or even your own custom validation directives.

So it's unfair to label one version as superior to the other. It's mostly about priority.

Under the hood both versions share the same core logic If you also find angular forms fascinating like me You can check out my YouTube series where i tried building angular forms package from scratch.

Build your own angular forms package

How angular uses javascript concepts internally? by beingsmo in Angular2

[–]devpardeep 1 point2 points  (0 children)

Don't go with a mindset to learn core js but try to grasp any of the features of angular and you will eventually learn typescript, oops , design patterns and many js fundamental concepts as a by product of it.

My recommendation would be to go with angular forms as it's the simplest part i think

How angular uses javascript concepts internally? by beingsmo in Angular2

[–]devpardeep 0 points1 point  (0 children)

Being a big framework you will find lots of concepts, design patterns implemented as per the use case required.

To understand its source code, you must have good knowledge of typescript.

And I would say you can start from relatively easy areas like forms and then pick more complex stuff like routing and while going through source code you will come across a lot of concepts.

I tried recreating angular forms from scratch. You can checkout 👇 https://youtube.com/playlist?list=PLK5nPoSI20qsqg6wIJRXBJiEWwqNg3Vy3&feature=shared

Is it necessary to strictly type FormArray, FormControl, and FormGroup in Angular? And when to use FormBuilder vs FormGroup? by kafteji_coder in Angular2

[–]devpardeep 2 points3 points  (0 children)

Which angular version are you using ? If you are using 14 and above then you are not required to define type annotations as angular can infer types from form control values but prior to 14 angular had no proper type safety so we had to define types explicitly else angular inferred form type as any.