Angular 2 / Ionic 2:将数据发布到数据库

时间:2017-05-22 21:57:39

标签: html5 angular ionic2

我正在开展一个小型离子2项目。我已经陷入困境。 我的问题在于组件部分。 有人可以帮我弄清楚如何去做:

**<!--TEMPLATE-->**


<select #selected>
<option value="">Choose your details here..</option>

<option *ngFor="let employee of employees; let i = employee" 
[value]="employee.employee_id">

  {{employee.employee_id}}: {{employee.first_name}} 
{{employee.last_name}}

</option>

</select><br><br>

<form>

  <button ion-button (click)="onCheckIn(selected.value)"><ion-icon 
name="person"></ion-icon>&nbsp;&nbsp;Check-In</button>
  <button ion-button (click) ="onCheckOut(selected.value)"><ion-icon 
name="person"></ion-icon>&nbsp;&nbsp;Check-Out</button>

</form>
    **// ALSO HAVE A MODEL CLASS**

  export class TimingModel {
  constructor(public employee_id:string,
  public check_in:Date,
  public check_out:Date,
  public check_date:Date,
  public active:boolean)
   {    }
 }

    **//COMPONENT**


onCheckIn(emp_id){

if(emp_id!==""){
let alert = this.alertCtrl.create({
title: 'Confirm checkout',
message: emp_id+', Do you want to checkout?',
buttons: [
   {
   text: 'Cancel',
   role: 'cancel',
   handler: () => {
  console.log('Cancel checkout: ',emp_id);
  return 
    }
  },
 {
text: 'Yes',
handler: () => {

 // I want to put here some logic here that will make use the model class 
 // to push data into the database as shown in the table.

     }
    }
  ]
 });
 alert.present();
  } else
  {
 this.presentToast();
  } 
}

要更新的表格:
The table to be updated

0 个答案:

没有答案