Avatar ·

How to get key and value of an object when using *ngFor in Angular?

Hello everyone! I'm new to Angular and TypeScript, and I have a problem when outputting data from an object using *ngFor.\n\nI have an object with user data, where the keys are user IDs and the values are objects with their information:\n\n```typescript\nusers = {\n 1: { name: 'Ivan', age: 25 },\n 2: { name: 'Maria', age: 30 },\n 3: { name: 'Petr', age: 28 }\n};\n```\n\nWhen I try to output this in the template using *ngFor, I don't understand how to get both the key and the value at the same time. Regular *ngFor for arrays works simply: `let item of items`, but for objects it doesn't work that way.\n\nI tried writing it like this:\n\n```html\n
\n

{{ user.name }}

\n
\n```\n\nBut Angular throws an error that you cannot iterate over an object. I read that you can use `Ob