I am working on login page. What I am trying to do is I have two function in a class validateLogin() and submit(). When clicking the login button my is successfully submitted and I am able to get the username and password.
I am trying to call my validateLogin function in my submit function but I am not able call it my sublime text shows an error on the validateLogin and I am not getting any error in my chrome Browser.
import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {FormBuilder,Validators} from "@angular/common";
@Component({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
public loginForm: any;
public commentOnTimeOut: any;
constructor(private navCtrl: NavController, public form:FormBuilder) {
this.loginForm = this.form.group({
"email":["",Validators.required],
"password":["",Validators.required]
})
}
validateLogin(cb){
window.setTimeout( () => {
if (this.loginForm.value.email == 'admin' && this.loginForm.value.password == 'admin123') {
console.log("invoking If part");
cb('valid User');
}
else {
console.log("invoking elsePart");
cb('Invalid User');
}
}, 3000);
}
submit(){
console.log(this.loginForm.value);
console.log(this.loginForm.value.email);
console.log(this.loginForm.value.password);
validateLogin(this.loginForm.value.email, this.loginForm.value.password, (response) => {
console.log(response);
this.commentOnTimeOut = response;
})
this.commentOnTimeOut = "Validating User";
console.log(this.commentOnTimeOut);
}
}
How can i call my function validateLogin in my submit function ?
Here is an demo plunker where it works good
Error:
GET http://localhost:8100/build/js/app.bundle.js in my console.
In my serve i get error like
TypeScript error: /home/panini/AutoSparParts/app/pages/home/home.ts(40,5): Error TS2663: Cannot find name 'validateLogin'. Did you mean the instance member 'this.validateLogin'?
the above error i am invoking any help