title: login button not working in ionic when clicked.
body: <p>hi i have a code when i click login button this message appers .in these code i get an error like :when i press login i get an error which image i have provided here like that.i am not able to find out whats the problem please do help me.</p>
  
  <pre><code>         than you in advance
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/5Bgj2.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>my code goes like this
  account-service.ts</p>
  
  <pre><code> import { Injectable } from '@angular/core';
   import { Http,Headers,RequestOptions,RequestMethod} from '@angular/http';
   import {Observable} from 'rxjs/Observable';
   import 'rxjs/add/operator/map';
   //import{Observable} from 'rxjs';
  
    @Injectable()
   export class AccountServiceProvider {
  constructor(private http:Http) {
    }
   new(user,pass){
   var _url="http://localhost:14164/api/Login";
   var _body={"username":user,"password":pass};
   var _header=new Headers({'Content-Type':'Application/json'});
   var _option=new RequestOptions({method:RequestMethod.Post,headers:_header});
   return this.http.post(_url,_body,_option).map(res=&gt;res.json());
    }
  
    }
  </code></pre>
  
  <p>my  home.ts</p>
  
  <pre><code>     import { Component,ViewChild} from '@angular/core';
              import { NavController,AlertController, IonicPage,LoadingController, 
             Loading,ToastController } from 'ionic-angular';
             import { MainpagePage } from '../mainpage/mainpage';
             import { RegPage } from '../reg/reg';
             import { AccountServiceProvider} from '../../providers/account- 
               service/account-service';
                  import {Http} from '@angular/http';
              //import { HomePage } from '../home/home';
                        @Component({
  
    selector: 'page-home',
    templateUrl:'home.html'
  //  providers:[AccountServiceProvider]
    // template: '&lt;button ion-button full  [navPush]="newPgeGo" [navParams]="params"&gt;Login&lt;/button&gt;'
  })
  export class HomePage {
  
    //registerCredentials = { email: '', password: ''};
    userName:String;
    password:String;
  
  //  mainpage: MainpagePage;
  //  reg: RegPage;
  constructor(public navCtrl: NavController,
  public acc:AccountServiceProvider,
  public toastCtrl: ToastController
  ) {}
  
  signin(){
    this.acc.new(this.userName,this.password).subscribe(data =&gt; {
      if(data==null){
        let toast=this.toastCtrl.create({
          message:'fail',
          duration:2000
        });
        toast.present();
  
      }else{
  
        let toast=this.toastCtrl.create({
          message:'sucess',
          duration:2000
        });
        toast.present();
  
  
      }
    });
  }
  
  public createAccount() {
      this.navCtrl.push(RegPage);
    }
  
  
  }
  </code></pre>
  
  <p>and my home .html</p>
  
  <pre><code>&lt;ion-header&gt;
    &lt;ion-navbar&gt;
      &lt;ion-title&gt;Login&lt;/ion-title&gt;
    &lt;/ion-navbar&gt;
  &lt;/ion-header&gt;
  
  &lt;ion-content padding&gt;
     &lt;form (ngSubmit)="login()" #registerForm="ngForm"&gt;
       &lt;ion-row&gt;
              &lt;ion-col&gt;
                &lt;ion-list inset&gt;
  
                  &lt;ion-item&gt;
                    &lt;ion-input type="text" placeholder="Email" name="email" [(ngModel)]="userName" required&gt;&lt;/ion-input&gt;
                  &lt;/ion-item&gt;
  
                  &lt;ion-item&gt;
                    &lt;ion-input type="password" placeholder="Password" name="password" [(ngModel)]="password" required&gt;&lt;/ion-input&gt;
                  &lt;/ion-item&gt;
  
                &lt;/ion-list&gt;
              &lt;/ion-col&gt;
            &lt;/ion-row&gt;
  
            &lt;ion-row&gt;
              &lt;button ion-button full (click)="signin()"&gt;Login&lt;/button&gt;
            &lt;/ion-row&gt;
  
          &lt;/form&gt;
  
          &lt;ion-row&gt;
            &lt;button ion-button class="register-btn" block clear (click)="createAccount()"&gt;Create New Account&lt;/button&gt;
          &lt;/ion-row&gt;
  &lt;/ion-content&gt;
  </code></pre>