Malik Kashmiri Malik Kashmiri - 3 months ago 21
TypeScript Question

TypeError: onEmailBlur is not a function

I am trying to call a function on blur but it show this error

TypeError: self._el_21.onEmailBlur is not a function
. I have no Idea why it showing this because I use some question but it perfectly working fine.

html



<input type="email" required [(ngModel)]='inviteUser.email'
(blur)="onEmailBlur()">


component



import { Component, Inject } from '@angular/core';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import { UserService} from '../../services/user.service';
import { OnInit} from '@angular/core';
@Component({
selector: 'invite-user',
templateUrl: '../../app/components/user/invite-user.html',
providers: [UserService, HttpHelper, NotificationsService],
directives: [MODAL_DIRECTIVES, SimpleNotificationsComponent]
})

export class InviteUserComponent {
// InviteUserForm: FormGroup;

isValidForm: Boolean = false;

ngOnInit() {


}
public onEmailBlur() {
alert('here');
}
}

Answer

Your code works for me. Maybe you made the same mistake I did when trying to implement your code a few minutes ago - I didn't start my compiler, so onEmailBlur() from .ts file wasn't compiled to .js, resulting in onEmailBlur is not a function error.