Http Resource is not firing when the signals inside change - Angular 19 (Experimental)

Discussão em 'Angular' iniciado por Naren Murali, Abril 22, 2025.

  1. Naren Murali

    Naren Murali Guest

    I am learning about httpResource and I can notice that the httpResource signal is not firing when the signal used to generate the URL is changed.

    Angular.dev - HttpResource Docs

    Below is a simple example highlighting my challenge.

    @Component({
    selector: 'app-root',
    imports: [FormsModule, CommonModule],
    template: `
    <input [(ngModel)]="id" type="number"/>
    <hr/>
    <div>{{api.value() | json}}</div>
    `,
    })
    export class App {
    id = signal<number>(2);
    api = httpResource(`https://jsonplaceholder.typicode.com/todos/${this.id()}`);
    }

    Stackblitz Demo


    Angular version: 19

    Continue reading...

Compartilhe esta Página