我需要触发用户选择的日期以在数据库中进行研究。 但是我需要在日历中选择另一个日期时赶上活动。
这是我的HTML代码:
<ion-calendar #calendar
[events]="currentEvents"
(dateSelected)="onDateSelected($event)"
(onCurrentDatechanged)="onCurrentDatechanged($event)"
(onEventSelected)="onEventSelected($event)"
(onTitleChanged)="onTitleChanged($event)"
(onTimeSelected)="onTimeSelected($event)"
step="30"
lang="es">
</ion-calendar>
和ts模块代码:(我尝试了很多方法来捕获事件,但无法做到)
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { DatabaseProvider } from '../../providers/database/database';
/**
* Generated class for the ConsultaPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-consulta',
templateUrl: 'consulta.html',
})
export class ConsultaPage {
constructor(
public navCtrl: NavController,
public navParams: NavParams,
private database: DatabaseProvider
) {
this.currentEvents = [
{
year: 2018,
month: 6,
date: 25
},
{
year: 2018,
month: 6,
date: 26
},
{
year: 2018,
month: 6,
date: 11
},
{
year: 2018,
month: 6,
date: 27
},
{
year: 2018,
month: 11,
date: 26
}
];
}
ionViewDidLoad() {
}
GetAllUsers(){
this.database.GetAllUsers().then((data: any) => {
console.log(data);
this.ListUser = data;
}, (error) => {
console.log(error);
})
}
onDateSelected() {
alert('asd');
}
onCurrentDatechanged($event){
alert('onCurrentDatechanged');
}
onEventSelected($event){
alert('onEventSelected');
}
onTitleChanged($event){
alert('onTitleChanged');
}
onTimeSelected($event){
alert('onTimeSelected');
}
}
当我选择另一个日期时,什么也没发生!
答案 0 :(得分:0)
由于您的HTML代码中的输入错误,您的“ onCurrentDatechanged”无法正常工作。您编写的“ onCurrentDatechanged”不正确。它应该是“ onCurrentDateChanged”。请在下面找到修改后的HTML代码:
int count = 1