import { Component, OnInit } from '@angular/core'; import { Headers, Http, Response, RequestOptions, URLSearchParams } from '@angular/http' @Component({ selector: 'app-shop', templateUrl: './shop.component.html' }) export class ShopComponent implements OnInit { private data; private message: string; private headers = new Headers({}); constructor(private http:Http){}; ngOnInit(){ //this.getData(); } login (email: string,password: string) { this.message = 'Please wait...'; let options = new RequestOptions({ headers: this.headers, search: new URLSearchParams('email=' + email + '&password=' + password + '&action=login') }); //this.http.get('http://www.ravistailor.com/android/web_service.php', options).subscribe(res => this.data = res.json()); this.http.get('http://www.ravistailor.com/android/web_service.php', options).subscribe(res => { //this.data = res.json(); var resJson = res.json(); if(resJson['id'] == null){ this.message = 'User not exit!'; }else{ this.message = resJson['id']; } }); } getData(){ let options = new RequestOptions({ headers: this.headers, search: new URLSearchParams('username=John&lastName=Smith}') }); this.http.get('http://www.ravistailor.com/android/web_service.php', options).subscribe(res => this.data = res.json()); //this.http.post('http://www.ravistailor.com/android/web_service.php', creds, {}).subscribe(res => this.data = res.json()); } }