I am injecting form validators into a service. I have the following code from the article

 * Error formaters.
export const defaultErrors = {
  required: (error: any): string => `This field is required.`,
  minlength: ({requiredLength, actualLength}): string => {
    return `Expect ${requiredLength} but got ${actualLength}`;

 * Error formaters injected.
export const FORM_ERRORS = new InjectionToken('FORM_ERRORS', {
  // providedIn: 'root',
  factory: () => defaultErrors

It produces the error.

 is missing the following properties from type 'TypeProvider': apply, call, bind, prototype, and 5 more.

I understand that I need to read the documentation carefully... It is still unresolved.

1 Answers

viktor.likin On

Sorry, the problem was childish. I injected this way.

@inject(FORM_ERRORS) private errors,

The right is with capital I

@Inject(FORM_ERRORS) private errors,