0

I have own class with dependency:

export class PeriodClass {

public constructor(
  private educationPeriodService: EducationPeriodService){}
}

I use this class in component:

@Component({
  providers: [PeriodClass]
});

class ComponentClass {
  public constructor(public classPeriod: PeriodClass) {
  }
}

It gives me an error:

Uncaught Error: Can't resolve all parameters for PeriodClass: (?, ?).

Cause when I inject PeriodClass in component I dont pass dependency EducationPeriodService, how to?

1

2 Answers 2

2

To inject a class/Service to component, make sure it is:

  1. marked as @Injectable()
  2. Added to List of Providers in the module/component where it's used.
Sign up to request clarification or add additional context in comments.

Comments

1

Add the @Injectable annotation to your PeriodClass.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.