离子模式 - onshow 事件? (angular)
ionic modal - onshow event? (angular)
有什么方法可以让我收听离子模态的 onshow 事件吗?
我的示例代码:
async presentTestModal() {
const modal = await this.modalController.create({
component: TestPage,
cssClass: 'TestPage'
});
return await modal.present();
}
在我的 class 上是这样的:
import { Component, OnInit } from '@angular/core';
import { $ } from 'jquery';
@Component({
selector: 'app-test',
templateUrl: './test.page.html',
styleUrls: ['./test.page.scss'],
})
export class TestPage implements OnInit {
constructor() { }
ngOnInit() {
// bind here
this.onshow += this.updateCounterUI(3);
}
updateCounterUI(countdown:number){
// do something here
}
}
编辑: 我已经尝试在我的组件上使用 ionModalDidPresent
方法,但是当组件显示时这不会执行
你可以这样做。在模态组件中,当您关闭模态时,在那里处理计数器:
async closeModal() {
await this.modalCtlr.dismiss();
this.counter + 1; // Put your logic here, and pass it up the chain
this.navCtlr.navigateRoot(`/main`);
}
有什么方法可以让我收听离子模态的 onshow 事件吗?
我的示例代码:
async presentTestModal() {
const modal = await this.modalController.create({
component: TestPage,
cssClass: 'TestPage'
});
return await modal.present();
}
在我的 class 上是这样的:
import { Component, OnInit } from '@angular/core';
import { $ } from 'jquery';
@Component({
selector: 'app-test',
templateUrl: './test.page.html',
styleUrls: ['./test.page.scss'],
})
export class TestPage implements OnInit {
constructor() { }
ngOnInit() {
// bind here
this.onshow += this.updateCounterUI(3);
}
updateCounterUI(countdown:number){
// do something here
}
}
编辑: 我已经尝试在我的组件上使用 ionModalDidPresent
方法,但是当组件显示时这不会执行
你可以这样做。在模态组件中,当您关闭模态时,在那里处理计数器:
async closeModal() {
await this.modalCtlr.dismiss();
this.counter + 1; // Put your logic here, and pass it up the chain
this.navCtlr.navigateRoot(`/main`);
}