简体   繁体   中英

ERROR Error: Uncaught (in promise): invalid link: SosPopPage

I am coding a SOS page, when I click the button that I want it showing a popup page like this. Then user can choose phone number.

在此处输入图片说明

sos.html page

<button ion-button color="light" (click)="openSosPop()">Call</button>

sos.ts page

openSosPop() {
  this.openModal('SosPopPage');
  // let contactModal = this.modalCtrl.create(SosPopPage);
  // contactModal.present();
}

openModal(pageName) {
  this.modalCtrl.create(pageName, null, { cssClass: 'inset-modal' })
    .present();
}

sos.css page

ion-modal.inset-modal {
  // transparent black background overlay
  background-color: rgba(0, 0, 0, .5) !important;
  transition: opacity .25s ease-in-out;
  padding: 20vh 10vw;
}

I am not using lazy loading

If you are not using lazy loading , it is not an IonicPage . Adding IonicPage decorator allows you to use string names to handle pages.

This will automatically create a link to the MyPage component using the same name as the class, name: 'MyPage'. The page can now be navigated to by using this name.

Since you are not lazy loading, you cannot use a string to navigate or create modals and popups. You have to use the actual page/component.

Import the page.

import <path_to_page>;

  this.openModal(SosPopPage);//create the modal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM