Angular 16 Signal update doesn't update view

Discussão em 'Angular' iniciado por kkleczek, Dezembro 14, 2024.

  1. kkleczek

    kkleczek Guest

    I am testing angular 16 signals and per my understanding, when I disable zone.js and call signal.update() the view should be updated with new value. It is not. Please help me to understand why.

    main.ts

    platformBrowserDynamic().bootstrapModule(AppModule, { ngZone: 'noop' })
    .catch(err => console.error(err));


    app.component.ts

    @Component({
    selector: 'app-root',
    template: '
    <h1>{{ title() }}</h1>
    <button (click)="click()">Change</button>
    ',
    })
    export class AppComponent {
    title = signal('Hello');

    click(): void {
    this.title.update((value) => value + "!!");
    }
    }


    I am expecting that after button click, value of 'title' will be updated from 'Hello' to 'Hello!!'. It is not updated.

    Continue reading...

Compartilhe esta Página