detect the dismissal event in the modal controller from the main component

Within my MainPage, I invoke the create function in the ModalController, which displays the ModalPage. Upon clicking cancel, the dismiss function is called and we are returned to the MainPage. The process functions as expected.

@Component({
  selector: 'main-page',
  templateUrl: 'main-page.html'
})
export class MainPage{
   itemTapped($event, item) {
       let detModal = this.modalCtrl.create(ModalPage, {item : item});
       detModal.present();
   }
}


@Component({
  selector: 'modal-page',
  templateUrl: 'modal-page.html'
})
export class ModalPage{
   dismiss() {
     this.viewCtrl.dismiss();
   }
}

Currently, I am seeking a way to trigger a function in the MainPage once the ModalPage has been dismissed. Is there a method available for achieving this?

Answer №1

If you want to utilize the onDidDismiss function (documentation), you can follow this example:

export class HomePage{
   itemClicked($event, item) {
       let newModal = this.modalCtrl.create(ModalView, {item : item});

       newModal.onDidDismiss(() => {
         // This code will run once the modal is closed...
         console.log('Hello...');
       });

       newModal.present();
   }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Enhancement of Nebular Theme from version 4.4.0 to 9.0.1 in relation to Angular (from 8.2.3 to 13.2.1)

Upon upgrading from Nebular Theme version 4.4.0 to 9.0.1 and Angular version 8.2.3 to 13.2.1, I encountered the following issues: 'nb-card-header' is not recognized as a valid element: If 'nb-card-header' is an Angular component, ens ...

Why is it necessary to redefine the interface and its class in Typescript after initially defining the interface with implements?

interface Filter { rowAddRow: (treeData:Tree[],id:string,filterType:FilterType) =>Tree[] } class FilterAction implements Filter { // I must redeclare here to ensure the correct type for id rowAddRow(treeData:Tree[], id, filterType):Tree[] { ...

Error encountered during conversion from JavaScript to TypeScript

I am currently in the process of converting JavaScript to TypeScript and I've encountered the following error: Type '(props: PropsWithChildren) => (any[] | ((e: any) => void))[]' is not assignable to type 'FC'. Type '(a ...

Can builtins like DOM globals be explicitly imported?

The present situation includes the utilization of rollup (as well as iife parameters), but I am hesitant about whether it is solely related to rollup or typescript. My objective is to achieve something similar to this: import { document } from "[wherever ...

Utilizing ngx-translate in Angular6 to dynamically load translations by making an API request to the backend

Using ngx-translate in my frontend, I aim to dynamically load translations upon app launch. The backend delivers a response in JSON format, for example: { "something: "something" } Instead of utilizing a local en.json file, I desire to integrate thi ...

Angular 2 form controls featuring custom display names and unique values

As I work on developing a form, I have encountered the need to display something different than the content itself. Here's what I currently have in my code: <ion-label>Rate</ion-label> <ion-input text-right detail-push formContro ...

typescript error: referencing a variable before assigning a value to it in function [2454]

I am currently in the process of creating a store using nextJS I have two variables that are being assigned values from my database through a function let size: Size let ribbonTable: Ribbon async function findSizeCategory(): Promise<v ...

UI5 Tooling generated an error stating that "sap is not defined" after a self-contained build

Having successfully developed an application using SAPUI5 1.108, I encountered a setback when attempting to deploy it to a system running SAPUI5 version 1.71. The older version lacks certain features, causing the application to fail. In order to address th ...

The HTTP DELETE request encountered a TypeError, stating that error.json is not a valid function

Within my Angular application, there is a feature that involves a "delete button". When this button is clicked, a confirmation popup appears asking the user if they are certain they want to proceed with the deletion. If the user confirms by clicking ' ...

Navigating to the tsconfig.json file based on the location of the file being linted

In my monorepo, each package currently contains a .eslintrc.cjs file with the following setup: Package-specific ESLint Configuration const path = require('path') const ts = require('typescript') const OFF = 0 const WARN = 1 const ERROR ...

Discover the latest Angular edition through coding

Is there a simple way to display my Angular version on a website using code instead of checking it in the command line with 'ng --version'? ...

"Exploring the dynamics of component communication in Angular 2

I am faced with a dilemma involving the app component, header component, and home component. In the app component template, I utilize <header></header> to incorporate the header component. Now in the home component, I am seeking a way to acces ...

Is it possible to retrieve 2 arguments within a function in a non-sequential manner?

Let's say there is a function with arguments A, B, C, D, and E. Function(A, B, C, D, E) However, not all arguments are needed all the time. For instance, only A and C are needed in some cases. Currently, I would have to call the function like this: Fu ...

Issue when generating Angular production build due to module not being found

I've encountered a problem while building an Angular module with angular cli and calling it in another project. Everything works fine when I run ng serve, but I am facing an error when running ng build --prod: ERROR in ./node_modules/my-module/dis ...

Postman issue: Your username and password combination is incorrect within the MEAN stack environment

I am new to mean stack development and facing some issues. When I try to run "api/users/login" in Postman, it shows an error saying "Username or password is invalid!". Additionally, when attempting to register using "register/users/register", it gives a me ...

Using Rxjs to handle several requests with various headers

I have a specific requirement where, if hasProcessado == true, 10 additional requests should be made before issuing the final request. If the final request fails, 3 more attempts are needed. Furthermore, when sending the last request, it is essential to n ...

Angular 4 allows you to assign unique colors to each row index in an HTML table

My goal is to dynamically change the colors of selected rows every time a button outside the table is clicked. I am currently utilizing the latest version of Angular. While I am familiar with setting row colors using CSS, I am uncertain about how to manip ...

Error: JSON parsing error - Unexpected token at the start of the JSON data when using JSON.parse() function

Backend code router.route('http://localhost:5007/api/media') .post(mediaCtrl.saveMedia) async saveMedia(req, res) { let file = req.files.file let ext = req.body.extension let path = req.body.path if(_.isNull(file) || _.isEmp ...

How do I make functions from a specific namespace in a handwritten d.ts file accessible at the module root level?

Currently, I am working on a repository that consists entirely of JavaScript code but also includes handwritten type declarations (automerge/index.d.ts). The setup of the codebase includes a Frontend and a Backend, along with a public API that offers some ...

Differences between Integrated and Isolated Testing in Angular 2

Can you explain the key distinctions between Integrated testing and Isolated testing? In what scenarios would these testing methods be recommended for use? ...