Avatar ·

Error when injecting service into Angular component: "EXCEPTION: Can't resolve all parameters for component"

Hi everyone! I'm new to Angular and TypeScript, and I've encountered a very strange error when trying to inject a service into one of my components. The error appears in the browser console: "EXCEPTION: Can't resolve all parameters for MyComponent: (?). Make sure that all the parameters are decorated with Inject or have valid type annotations".\n\nHere's my code. I have a simple service for working with users:\n\n```typescript\n// user.service.ts\nexport class UserService {\n private users = ['Alice', 'Bob', 'Charlie'];\n\n getUsers(): string[] {\n return this.users;\n }\n}\n```\n\nAnd the component that should use this service:\n\n```typescript\n// my.component.ts\nimport { Component } from '@angular/core';\nimport { UserService } from './user.service';\n\n@Component({\n selector: '