Can't resolve all parameters for component in Angular


angular Tutorials

Sometimes you can get this error while running tests or in the browser console.

Also, you can face this error after updating the Angular version:

Can't resolve all parameters for AppComponent: (?)

Most сases can be resolved by adding following line in the tsconfig.json:

   "compilerOptions": {
     "emitDecoratorMetadata": true,
     "outDir": "./out-tsc/spec",

With this parameter, you can forget about adding @Inject() to your function parameters. For some versions of Angular, it should be enabled by default.

If you are using decorators and got this error, please check the following: - have you added decorators in all necessary places? - have you typed correctly the decorator’s name with all symbols?

It should look like this:

@Injectable()
export class Service { ... }
comments powered by Disqus