typescript - 导航完成后模态自动关闭
问题描述
自定义模式是否可以通过导航关闭?我认为this.modalDialogParams.closeCallback()
只能追溯到其原始组件。我希望模式在导航到所需目的地后关闭。谢谢你的回答!
这是我的html:
<StackLayout class="main-content">
<FlexboxLayout>
<Label text="" textWrap="true" class="fas h3 m-t-10 m-r-10 p-10"></Label>
<Label text="Delete Account" textWrap="true" class="m-t-10 h2"></Label>
</FlexboxLayout>
<Label text="Are you sure you want to delete your account?" textWrap="true" class="m-y-10 h3 text-center"></Label>
<FlexboxLayout>
<Button class="btn btn-primary" text="Delete" (tap)="onUpdate()"></Button>
<Button text="Cancel" (tap)="goBack()"></Button>
</FlexboxLayout>
</StackLayout>
打字稿:
import { Router } from "@angular/router";
import { AuthService } from "~/app/services/Auth/auth.service";
import { Component, OnInit } from "@angular/core";
import { ModalDialogParams } from "@nativescript/angular";
@Component({
selector: "DeleteAccount",
templateUrl: "./DeleteAccount.component.html",
styleUrls: ["./DeleteAccount.component.css"]
})
export class DeleteAccountComponent implements OnInit {
show = false;
constructor(
private modalDialogParams: ModalDialogParams,
private auth: AuthService,
private router: Router
) {}
ngOnInit() {}
onUpdate() {
this.auth.deleteAccount();
}
goBack() {
this.modalDialogParams.closeCallback();
}
}
服务:
deleteAccount() {
firebase.deleteUser().then(
function() {
console.log("deleted")
},
function(errorMessage) {
console.log(errorMessage);
}
);
}
解决方案
推荐阅读
- javascript - 如何检查 Chrome 移动浏览器中是否授予/阻止了增强现实权限?
- c# - 如何在 C# 中控制并行 For 循环的 FileWrite?
- php - 受密码保护的子文件夹两次提示密码然后抛出 404 错误
- spring - 如何在单独的表格中正确显示枚举?
- html - 如何只显示一个同名的班级
- r - 有条件地替换数据框中的值(通过其他地方的值)
- c++ - 奇数有问题
- android - 处理程序不会停止,handler.removeCallbacksAndMessages(null) 在 android (kotlin) 的片段中不起作用
- react-native - React Native Expo 移动应用中的 HLS m3u8 直播
- python - 如何扩展 Django 的用户模型