-3

I have created an Angular 21 app by using the CLI. Zone.js was generally uninstalled beforehand.

I made a simple test app with two counter buttons.

One button updates a signal, and the other updates a plain number. Both button works fine.

As I understand, zoneless Angular requires signals for correct updating but not plain number variables.

Here is my template:

template: '' +
    'Y: {{Y}}\n' +
    '<button (click)="updateY()">Y++</button>\n' +
    '<br>\n' +
    'X: {{X()}}\n' +
    '<button (click)="updateX()">X++</button>',

And the component code:

  public Y=0
  public X=signal(0)

  updateY(){
    this.Y++
  }

  updateX(){
    this.X.update(()=> this.X()+1)
  }

Is the use of a plain variable correct anymore?

Complete code is available on StackBlitz: https://stackblitz.com/edit/stackblitz-starters-hsznsgww?file=package.json

2
  • StackBlitz link doesn't work? Commented Nov 21 at 20:45
  • now the stchBlitz link is O.K, but StackBlitz is V20. So code is only excample. Commented Nov 22 at 9:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.