Angular · Senior · Question 10 of 75

What does httpResource (the resource API) provide?

userId = input.required<string>();
user = httpResource<User>(() => `/api/users/${this.userId()}`);
// template: @if (user.isLoading()) { ... } {{ user.value()?.name }}

Explanation

Resources bring async data into the signal graph. When userId changes, the previous request is aborted and a new one starts. reload() refetches manually.

Further reading

Problem with a question

Angular · Senior · question 10

Test yourself

Take the Angular · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz