shlogg · Early preview
Connie Leung @railsstudent

Angular 19.2.0 Resource API DefaultValue Option

The Resource API in Angular 19.2.0 introduces a defaultValue option that overrides undefined, returning type T instead of T | undefined. This allows developers to provide a default value when the resource is undefined, loading or has an error.

The Resource API includes resource and rxResource functions whose default value is undefined. When developers only provide a loader, the return type of the functions is T | undefined. In Angular 19.2.0, the Resource API will add a defaultValue option that overrides the undefined, and the functions return type T.  This default value is used when the resource is undefined, loads data, or throws an error. 
In this blog post, I will show you how to use the defaultValue option to return a dummy Person object in the rxResource function. 

  
  
  Add defaultValue option to the Resource API...