I want to reference the keyword "this" in a typescript class in my Angular project. But it cannot be used. I always get the error that the variable I want to change is not defined. Here is my implementation:
export class ContactComponent implements OnInit {
contactForm: FormGroup;
errorMsg:string = '';
redirect = "";
loggedIn(): void {
this.redirect = "dashboard";
console.log("success");
in my HTML the redirect variable is connected to a routerLink like this:
<a [routerLink]="redirect"></a>
I have tried this with other variables in other functions but had always the same error.
EDIT:
The loggedIn function is called within another function as "success" parameter like this:
submitForm(): void {
DBEventProxy.instance().dbevent.login(this.contactForm['username'],
this.contactForm['password'], this.loggedIn, this.failed);
}
The login function needs the parameters username, password, success function, failfunction.