Sending information to a component through ModalController's create() method

How can I pass the itemId parameter to MarketPlaceItemPage for it to use that information?

async presentMarketplaceItem(itemId: number) {
    const modal = await this.modalController.create({
      component: MarketplaceItemPage,
      cssClass: '',
      mode: 'ios',
    });
    return await modal.present();
  }

I've searched through the Ionic documentation but haven't found a solution yet. Appreciate any help in advance!

Answer №1

I stumbled upon a solution that actually works on this awesome website

async openMarketplaceItem(itemId: number) {
    const modal = await this.modalController.create({
      component: MarketplaceItemPage,
      componentProps:{
        id: itemId
      },
      cssClass: '',
      mode: 'ios',
    });
    return await modal.present();
  }

Answer №2

Check out the official Ionic documentation here

The specific property you need to use is componentProps. In the current version 5 documentation of Ionic, controllers are not listed but they were included in version 4.

Another quicker way (in my opinion) is to directly browse through the source code (ctrl+click), which will show you the method signature for the controller.

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

Transforming XML into Json using HTML string information in angular 8

I am currently facing a challenge with converting an XML document to JSON. The issue arises when some of the string fields within the XML contain HTML tags. Here is how the original XML looks: <title> <html> <p>test</p> ...

Make sure to wait for a Promise to resolve before initiating another Promise within a for loop in Angular

Issue: I am trying to call multiple APIs in sequence within a for loop and need each API call to wait for the previous one to resolve before making the next call. Within my code, I have a for loop that calls a Get API to generate documents on the server s ...

What is the classification of the socket entity?

After searching through various posts, I couldn't find a solution to my problem so I decided to create my own thread. The issue I'm facing is determining the correct type for the 'socket' instance that I'm passing as a prop to my ...

How to align text in sorted columns using Angular 16 Material 16

I'm having an issue with styling a table that includes sorting columns. I am using the material table component. table mat-table [dataSource]="data" class="example-table" matSort > <!-- Created Column --> < ...

In Typescript, you can easily group a string into sections that consist of digits like 345-67, along with text containing a

I have a string that looks like this: "[111-11] text here with digits 111, [222-22-22]; 333-33 text here" and I am trying to parse it so that I can extract the code [111-11], [222-22-22], [333-33] along with their respective text descriptions. The challeng ...

Enhancing an OpenAI feed within a NextJS environment

I've come across some examples utilizing the Vercel ai library to efficiently generate a streamable OpenAI response type (for instance, see ), but I am interested in performing data manipulation before sending out a response. Can this be achieved usi ...

Tips for implementing self-managed state in Vue.js data object

My approach in organizing my Vue application involves using classes to encapsulate data, manage their own state (edited, deleted, etc), and synchronize with the back-end system. However, this method seems to conflict with Vue in some respects. To illustra ...

Creating a custom component in Angular that utilizes ngModel

I am working with the following HTML and aiming to keep myModel synchronized whenever there are changes in either input or my-component. <input type="text" [(ngModel)]="myModel" /> <my-component [(ngModel)]="myMdoel></my-component> Any ...

The <table mat-table> element seems to be failing to display any content

I'm currently developing an app that showcases user information, and I'm using the angular/materials library to create a table. However, I'm encountering an issue where the mat-table isn't displaying the column titles. I've attemp ...

Arranging MatCheckbox items in Angular in a specific order

I am currently implementing a solution found in the following link: matcheckbox Is it possible to sort checked checkboxes in alphabetical order first and unchecked checkboxes in alphabetical order second when clicking/un-clicking the mat-checkbox control ...

Separating the time and date into distinct variables offers flexibility in how they

Struggling with formatting time in a web component using TypeScript and React. The code below is working: new Date(myDate) .toLocaleTimeString( 'en-US', { weekday: 'short', year: 'numeric', month: 'short', ...

Changing email case with Angular reactive forms upon submission

I have a reactive form that allows users to enter email addresses with uppercase characters before the '@' symbol. However, I need to convert a valid email address like '[email protected]' to '[email protected]' onSu ...

Middleware fails to execute on routing in Nextjs 13.4 application

Something's not quite right. I can't seem to get my middleware to run... Here's the code I'm using: export const config = { matcher: '/api/:function*', }; I specified this config so that it would run only when there's ...

I want to establish the identical response output field name in NestJS by utilizing the @Expose decorator from class-transformer

My Entity definition currently looks like this: export class ItemEntity implements Item { @PrimaryColumn() @IsIn(['product', 'productVariant', 'category']) @IsNotEmpty() itemType: string; @PrimaryColumn() @IsU ...

What is the process for importing type definitions from a custom module?

I am struggling with a particular issue and finding it difficult to search for a solution. Here is the problem: I have created a TypeScript class that I am exporting: class MyAPIClass { myMethod(one:number) : void; secondMethod(text:string) : number; ...

A guide on monitoring ngForm for changes and performing calculations based on the updated values

I am encountering an issue where I am unable to retrieve the updated input value from a reactive ngForm in order to perform the necessary calculation. Please refer to my requirements outlined in the attached screenshot. https://i.sstatic.net/IhGIZ.jpg for ...

Issues arise when attempting to utilize Async/Await with a gRPC method

Here is the code snippet used to initialize a gRPC server: export const initServer = async (finalPort: number): Promise<string> => { let initStatus = 'initial'; gRPCserver.addService(webcomponentHandler.service, webcomponentHandler.h ...

Trouble with communication between a pair of Angular2 components

Looking to share a value between 2 Angular2 components? The code for my App component is: <app-header></app-header> <router-outlet></router-outlet> <app-footer></app-footer> The typescript code for my login componen ...

What is the best way to ensure the TypeScript type is correct prior to making a

When preparing to commit my code in TypeScript, I want to ensure that the type is correct before proceeding. To achieve this, I use the command tsc --noEmit $(changedFile). However, this command does not allow for the specification of a config file. While ...

Placing an image on the chosen option of a <mat-select> using Angular Material

I have incorporated Angular Material into my Angular 2 project, and I am trying to insert a static image (HTML element) in the selected value of mat-select. Unfortunately, I have been unable to find a solution for this issue. Is there anyone who can ...