Implementing selectSignal in Component-Store with Angular's New Template Syntax

Simplify your HTML code using the modern Angular template syntax

Implementing selectSignal in Component-Store with Angular's New Template Syntax

Photo by Glen Carrie on Unsplash

In this article, we'll explore more about component-store with Angular. Instead of using the usual selectors, we'll use selectSignal from component-store. At the same time, we'll update our template to include the advanced template syntax introduced in Angular 17.


We'll use selectSignal instead of select() because it helps show view-related changes in the store and includes the new Angular template syntax. Some advantages we get are:

  • Eliminate the use of the async pipe

  • Simplify the template with @if to manage the loading state

  • Use @for and @empty to display the options

  • Avoid overusing ng-container and ng-template to handle the async pipe and display different templates

What we'll change

First, the store,

// from normal selectors
  readonly series$ = => state.series);
  readonly isLoading$ = => state.state === 'loading');

// to use selectSignal
  readonly seriesSignal: Signal<Serie[]> = this.selectSignal(
    (state) => state.series
  readonly isLoadingSignal: Signal<boolean> = this.selectSignal(
    (state) => state.state === 'loading'

By using selectSignal, it retrieves a Signal from the store not an observable.

Second, the component

// series.component.ts
// viewModel from the store removed
readonly vm$: Observable<ViewModelComponent> =$;

// converted to selectSignal()
readonly vm: Signal<ViewModelComponent> =

// viewModel replaced

We now have the same View Model, but it's a Signal instead.

Third, the view,

<!--series.components.html -->
  @if (vm().isLoading){
        @for (item of vm().series; track;) {
        } @empty {
            <li>No series found</li>

We used the signal to show the information, and also, made use of the new Angular Template Syntax.


The new features in Angular 16 (Signals) and Angular 17 (New template syntax) make displaying information in Angular much simpler. These changes create a new way of handling things compared to before.

Right now, I think using observables with RxJs for handling data and requests is the best approach. For things related to the view, now I prefer using Signals.

You can see all the changes I made in the code by checking out this PR. It lets you compare what we changed.

Do you have any experiences with ComponentStore to share? Or any questions about what we discussed? I'd love to hear your thoughts and talk about them in the comments below.

Did you find this article valuable?

Support Arcadio Quintero by becoming a sponsor. Any amount is appreciated!