我正在将表单验证器注入服务。我有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
});
它会产生错误。
is missing the following properties from type 'TypeProvider': apply, call, bind, prototype, and 5 more.
我了解我需要仔细阅读文档...仍然无法解决。
答案 0 :(得分:0)
对不起,问题很幼稚。我以这种方式注入。
@inject(FORM_ERRORS) private errors,
右边是大写字母 I
@Inject(FORM_ERRORS) private errors,