I\'ve built a basic app in Angular, but I have encountered a strange issue where I cannot inject a service into one of my components. It injects fine into any of the three o
WRONG #1: Forgetting Decorator:
//Uncaught Error: Can't resolve all parameters for MyFooService: (?).
export class MyFooService { ... }
WRONG #2: Omitting "@" Symbol:
//Uncaught Error: Can't resolve all parameters for MyFooService: (?).
Injectable()
export class MyFooService { ... }
WRONG #3: Omitting "()" Symbols:
//Uncaught Error: Can't resolve all parameters for TypeDecorator: (?).
@Injectable
export class MyFooService { ... }
WRONG #4: Lowercase "i":
//Uncaught ReferenceError: injectable is not defined
@injectable
export class MyFooService { ... }
WRONG #5: You forgot: import { Injectable } from '@angular/core';
//Uncaught ReferenceError: Injectable is not defined
@Injectable
export class MyFooService { ... }
CORRECT:
@Injectable()
export class MyFooService { ... }