在Alertcontroller处理程序内,我想从API接收一些数据并将数据绑定到HTML页面中。但要等到单击页面后才能执行。 这是我的代码。
export class UserPage implements OnInit {
dataPage: any;
ngOnInit() {}
constructor(userService: UserService) {}
async alertFunction() {
const alert = await this.alertController.create({
header: 'Get data',
message: 'Getting data',
buttons: [{
text: 'get',
handler: (blah) => {
this.userService.getData().subscribe(r => {
this.dataPage = r;
});
}
}]
});
await alert.present();
}
我正在通过{{dataPage}}用HTML显示此dataPage,但它不起作用。