Home > Enterprise >  Angular V11: NullInjectorError: No provider for ControlContainer
Angular V11: NullInjectorError: No provider for ControlContainer

Time:11-26

I have a custom input made in accordance to this article: enter image description here

UPDATE 1: In components <app-input> is used in the following way ▼

enter image description here

CodePudding user response:

As it seems you use formControl without formGroup in some cases, so use @Optional decorator to have controlContainer null in those cases.

constructor(@Optional() private controlContainer: ControlContainer) {}
  • Related