I am new to Angular and I tried to use httpResource() to test by using the below method. But I am not able to display the result in UI. Please can somebody guide me?
import { JsonPipe } from "@angular/common";
import { httpResource, provideHttpClient } from "@angular/common/http";
import { Component } from "@angular/core";
import { bootstrapApplication } from "@angular/platform-browser";
export interface User {
name: string;
email: string;
}
@Component({
selector: "app-root",
imports: [JsonPipe],
template: `
<ul>
@for (user of usersResource | json ; track user) {
<li>{{ user }}</li>
}
</ul>
`,
})
export class App {
usersResource = httpResource<User[]>(
"https://jsonplaceholder.typicode.com/users"
);
}
bootstrapApplication(App, {
providers: [provideHttpClient()],
});