Angular 14, the latest version of the Google-developed, TypeScript-based web application framework, has arrived, featuring typed forms and a developer preview of standalone components.
Standalone components simplify the development of Angular applications by reducing the need for NgModules. With standalone components, directives, and pipes, the
standalone: true flag allows developers to add
imports directly in a
@component() without an
These components should be used for exploration and development only, as they are not a stable API and could change outside of Angular's typical model of backward compatibility.
Also in Angular 14, which was published June 2, reactive forms are strictly typed by default. Typed forms ensure that values inside of forms controls, groups, and arrays are type safe across the full API surface, enabling safer forms particularly for deeply nested complex cases.
Update schematics allow for incremental migration to typed forms. Developers can gradually add typing to existing forms with full backward compatibility. Also,
ng udpate will replace all form classes with untyped versions, allowing developers to enable types at their own pace.
To take advantage of the new typing support, the Angular development team advises searching for instances of the
Untyped forms controls and migrating to the new typed forms API surface where doable.
Other new features and improvements in Angular 14 include support for the latest TypeScript 4.7 release. Angular 14 targets ES2020 by default, allowing the CLI to ship smaller code with no need to down-level.
In addition, protected component members can be bounded directly from templates. This gives users more control over the public API surface of reusable components.
NgModel changes are reflected in the UI for OnPush components while optional injectors can be used when creating an embedded view. The injector allows the dependency injection behavior to be customised within the specific template. Cleaner APIs are enabled for reusable components and for component primitives in Angular CDK (Component Dev Kit).
Delving deeper, an experimental esbuild-based build system for
ng build is introduced, compiling to pure ECMAScript Module output. This is alongside new methods offered for
HarnessLoader to check if a harness is present and return the harness instance if present, plus new change detection and runtime optimisation guides on angular.io.