title: How to call one function in another function inside same controller in angular2
body: <p>I am working on login page. What I am trying to do is I have two function in a class <code>validateLogin()</code> and <code>submit()</code>. When clicking the login button my is successfully submitted and I am able to get the username and password.</p>
  
  <p>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. </p>
  
  <pre><code>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( () =&gt; {
          if (this.loginForm.value.email == 'admin' &amp;&amp; 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) =&gt; {
        console.log(response);
        this.commentOnTimeOut = response;
      })
  
      this.commentOnTimeOut = "Validating User";
      console.log(this.commentOnTimeOut);
    }  
  
  }
  </code></pre>
  
  <p>How can i call my function validateLogin in my submit function ?</p>
  
  <p>Here is an <a href="http://plnkr.co/edit/WgzSHh?p=catalogue" rel="nofollow">demo plunker</a> where it works good </p>
  
  <p><strong>Error:</strong></p>
  
  <blockquote>
    <p>GET <a href="http://localhost:8100/build/js/app.bundle.js" rel="nofollow">http://localhost:8100/build/js/app.bundle.js</a>  in my console.</p>
    
    <p>In my serve i get error like <code>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'?</code></p>
  </blockquote>
  
  <p>the above error i am invoking any help</p>