Angular6 在提供程序中使用useValue时无法编译代码

Angular6 在提供程序中使用useValue时无法编译代码,angular6,Angular6,该守则可于 这是一个注册表单,我正在尝试创建一个自定义验证程序。验证函数位于helper.service.ts中。我想以不同的方式验证verify password字段,并在helper.service.ts中创建了validateVerifyPassword函数。当使用signup component.components.ts中的Validators…函数验证所有其他字段时,我想使用signup component.component.html中的自定义指令验证验证密码字段 其他领域 las

该守则可于

这是一个注册表单,我正在尝试创建一个自定义验证程序。验证函数位于
helper.service.ts
中。我想以不同的方式验证
verify password
字段,并在
helper.service.ts
中创建了
validateVerifyPassword
函数。当使用
signup component.components.ts
中的
Validators…
函数验证所有其他字段时,我想使用
signup component.component.html
中的自定义指令验证
验证密码
字段

其他领域

lastName:[null,[Validators.required,Validators.pattern(/[A-Za-z]+/)]], 
email:[null,[Validators.required,Validators.pattern(this.EMAIL_PATTERN)]],       
password:[null,[Validators.required,Validators.minLength(8),this.helper.validatePassword]]
确认密码字段

<input id="verify-password" type="password" class="form-control" formControlName="confirmPassword" [ngClass]="validateField('confirmPassword')" ngModel validateVerifyPassword >
我做错了什么?错误是 src/app/validate-verify-password.directive.ts(8:39)中出现错误
validateVerifyPassword未定义
评估src/app/validate验证密码.directive.ts
评估src/app/app.module.ts
评估src/main.ts

启动应用程序

我能够解决它。我在
helper.service.ts
中的
HelperService
类中定义了
validateVerifyPassword
,即

export class HelperService {
validateVerifyPassword() {
}
}
我应该把它定义为类外的函数

export class HelperService {
}
function validateVerifyPassword() {
}
export class HelperService {
}
function validateVerifyPassword() {
}