Angular 4 - 如何使用参数将数据获取到数据库

I would like to know how to pass parameter from url to php using http service.

service:

  getEmployeesById(data) {
     let datas = JSON.stringify({'id':data});
      return this.http.get('http://localhost/employees/?p=editEmployees', datas)
    .map(response => response.json() );
  }

component:

ngOnInit() {
this.activatedRoute.queryParams.subscribe((queryParams: Params) => {
  let userId = queryParams['id'];
  this.employeesServices.getEmployeesById(userId)
    .subscribe(data => {
      this.result = data
    });
});

}

PHP : http://localhost/employees/?p=editEmployees

$editEmployees = mysqli_query($con, "SELECT * FROM $employeesTable WHERE emp_id = '".$_GET['id']."' ");
$rows = mysqli_fetch_assoc($editEmployees);
$emp[] = $rows;
echo json_encode($emp);

-I created a mysqli query that gets the employee id. -Then in component, I fetched the emp id from url param(id) like this

this.employeesServices.getEmployeesById(userId);

My problem is, I dont know If I am passing the data correct.

I display the data in html using

{{ result.first_name }}

but I cant get it right.

you can send it in the query string like you already sent p=editEmployees as parameter in the query string. You can simply append another parameter in the query string like this

getEmployeesById(data) { // as data is userId so simply append it 
      return this.http.get('http://localhost/employees/?p=editEmployees&id='+ data)
    .map(response => response.json() );
  }