首页 > 解决方案 > 导航完成后模态自动关闭

问题描述

自定义模式是否可以通过导航关闭?我认为this.modalDialogParams.closeCallback()只能追溯到其原始组件。我希望模式在导航到所需目的地后关闭。谢谢你的回答!

这是我的html:


<StackLayout class="main-content">
    <FlexboxLayout>
        <Label text="&#xf2ed;" 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);
          }
        );
      }

标签: typescriptnativescript

解决方案


推荐阅读