Thanks Angular.io and https://icons8.com/icons/set/form for images

Angular Forms Story: Alternatives

Georgi Parlakov
3 min readApr 10, 2020

--

Strong typing Forms libraries and articles overview.

Seems there’s a lot to be said about strongly typing @angular/forms

This is part of the Angular Forms Story series:

  • Angular Forms Story: A Dev Tool (link)
  • Angular Forms Story: Strong Types (link)
  • Angular Forms Story: The Whole Story (this one)

While looking into making my forms type-safe I found that a lot of people have already done a lot of work both as part of the Angular framework and external to the it. I’ll try to list and shortly summarize my findings here.

Here’s what we’ll see:

  • efforts internal to Angular to make using Angular Forms easy, type-safe, maintainable and scalable.
  • libraries trying to do the same from the outside
  • other articles on the subject
  • alternatives to strong typing your forms

Internal:

External

Some are only articles but the majority have exposed functionality via an npm package. Let’s start with them and then on the articles.

Packages

  • ngx-sub-form — the title says it all. Article talks in detail about nesting forms and extracting common form parts, boilerplate in a base class and. Article Building scalable robust and type safe forms with Angular.
  • ngx-strongly-typed-forms strongly typed forms packaged as a module (Angular module). From the docs: “…not backwards compatible with Angulars AbstractControl…”
  • @ng-stack/forms — wraps ReactiveFormsModule and strong types the forms, controls, validation everything. Looks like it’s in active development.
  • angular-typesafe-reactive-forms-helper — exposes types that replace @angular/forms types and exposes a type-safe FormsBuilder service that can be part of your Angular app. Article Angular Typesafe Reactive Forms With TypeScript.
  • ngx-forms-typed — type-your-forms package that exposes a few functions and types that you can use to strong-type your forms and connect parent-forms to child-forms. Article Angular Forms Story: Strong Types.
    This is the one I maintain.
  • @ajsf/core — Something of an oddball. It has typed forms, components. Seems like you need to tell these components which framework to use (material, bootstrap) which seems useful. But it’s a component-level @Input() config and not a module-level config as I would expect i.e. AjsfModule.forRoot({framework: 'material'}). It supports Angular as well as React and JQuery and others so that makes it a bit of a Formly (see below).
  • ngx-strong-forms — Adding strong types to forms. The caveat is that it looks like it’s not been updated for over a year.

Articles:

Alternatives

These represent different approaches to handling forms — JSON configured forms and global forms management.

  • Formly — The very popularJSON powered / Dynamic forms in Angular“ package @ngx-formly. It’s in a class of its own
  • @ngneat/forms-manager — A different approach — manage all your active form instances (form groups) using this package. As in anywhere in the app.

Thanks for reading! Did I miss your favorite library for handling forms? Please leave a comment!

--

--

Georgi Parlakov

Angular and DotNet dev. RxJs explorer. Testing proponent. A dad. Educative.io course author. https://gparlakov.github.io/