import { Component, OnInit, Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import { GuessService } from './guess.service';
import 'rxjs/add/operator/map';
import {Router} from '@angular/router';
declare var jQuery:any;
declare var $ :any;
@Component({
  selector: 'app-guess',
  templateUrl: './guess.component.html',
  styleUrls: ['./guess.component.css']
})
@Injectable()
export class GuessComponent implements OnInit {
  constructor(private router: Router) {}
  ngOnInit() {
  }
  CheckLogin(name,pass)
  {
    $.ajax({
      headers:{  
   "Accept":"application/json",//depends on your api
    "Content-type":"application/x-www-form-urlencoded"//depends on your api
      },   url:"http://199.188.207.196:5555/user/login/",
      method:"post",
      data:{"email":name,"password":pass},
      success:function(response){
        if(response.success == true){
        console.log("ok");
        this.router.navigate(['/main']);
      }
        else{
          console.log("backend");
        }
      }
    });
  }    
}
When user click on CheckLogin button then it must route to login component, but in my side it show error.
I found solution of my question in stackoverflow but it's not working, i don't know what is the problem.