我正在开展一个小型离子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> Check-In</button>
<button ion-button (click) ="onCheckOut(selected.value)"><ion-icon
name="person"></ion-icon> 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();
}
}