Search code examples
angularsignalsreactive-programmingangular-signals

Angular Signal Based Components. How do I use signals: true property in component decorator?


I want to try out a signal based component as described here: https://github.com/angular/angular/discussions/49682

I get an error when trying to use signals: true in the component decorator. The error says it is not a know property. I am using the latest version of Angular 16.2.0. Is there something I need to change in my angular.json or something like that to enable this feature?

here is my component decorator:

@Component({
  signals: true,
  standalone: true,
  selector: 'app-counter',
  imports:[CommonModule],
  template: ` <!-- count is invoked as a getter! -->
    <p>Count {{ count() }}</p>
    <p>{{ name }}</p>
    <!-- Not reactive! -->
    <button (click)="increment()">Increment count</button>`,
})

Solution

  • Signal based component aren't available/implemented yet and it is not known yet when they are supported to land.