在下面的typescript函数中,’this’不会解析为EmailValidator的实例.如何更正此功能,以便它解析为正确的EmailVaildator实例,以便我可以访问_registerServices?
class EmailValidator { constructor(private _registerServices: RegisterServices) { } isAvailable(c: AbstractControl): Promise<ValidationResult> { let q = new Promise((resolve,reject) => { this._registerServices.emailIsAvailable(antiForgeryToken(),c.value) .then(result => { // Need to actually check the result. resolve({ "emailtaken": true }) },error => { // Need to communicate the server error? Probably not. resolve({ "servererror": true }) }); }); return q; } }