#@Inject on everything?

1 messages · Page 1 of 1 (latest)

brazen cipher
#

Hi folks,
I'm in the process of upgrading a large v9 app to v12 (and beyond, hopefully). So far, it seems that I'm having to update every single constructor to use @Inject... Seems a bit odd to me:

constructor(
  @Inject(BsModalService) private modalService: BsModalService,
  @Inject(ExampleService) private exampleService: ExampleService,
) {}

Is this normal or is something else fundamentally wrong here?

Cheers!

inland grotto
#

No, you shouldn't have to do that. Why are you? What happens if you don't?

brazen cipher
#

Hey @inland grotto, thanks for the response! Essentially, it all compiles ok (with Rails/webpack dev server) but upon load, I get errors like the below:

ERROR Error: Uncaught (in promise): Error: This constructor is not compatible with Angular Dependency Injection because its dependency at index 0 of the parameter list is invalid.
This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.

Please check that 1) the type for the parameter at index 0 is correct and 2) the correct Angular decorators are defined for this class and its ancestors.
Error: This constructor is not compatible with Angular Dependency Injection because its dependency at index 0 of the parameter list is invalid.
This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.

Please check that 1) the type for the parameter at index 0 is correct and 2) the correct Angular decorators are defined for this class and its ancestors.

Adding @Inject "fixes" these errors, but feel that something else is at play here...

@Injectable does exist on the services.

full lava
#

Can you show your BsModalService please (with imports too)?