0

I would like to change the modal component parameter by a value from an array. But I don't know how to do it. When pass the array, it takes the code writing and not the array value.

componentArray: any[] = [{component: 'modal1Page'}, {component: 'modal2Page'}];

  async onClick(value: any) {
     const myModal = await this.modalController.create({ 
      component: this.componentArray[0],
      cssClass: 'modalCss',
      componentProps: {
        value: value,
      }
    });
    return await myModal.present();
  }

It's interpreting like this: " component: this.componentArray[0]; " and i would like it to be interpreting like this: " component: modal1Page; "

Thanks for your help

1 Answer 1

1

I think you just missed .component

async onClick(value: any) {
     const myModal = await this.modalController.create({ 
      component: this.componentArray[0].component,
      cssClass: 'modalCss',
      componentProps: {
        value: value,
      }
    });
    return await myModal.present();
  }
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so much !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.