[Solved] Error with ActionSheet and Ionic 3


#1

Hi I have an error with an ActionSheet with the last version of Ionic.
The error says No component factory. I understand that i have a component to declare in entry component. But before last update i didn’t have this error.
And i don’t know what component i have to declare !!!

Is this a bug ?
Thanks for your future answer


#2

Could you provide us with some code? Possibly from the page this error is causing and your app.module.


#3

Thanks for your answer.
The code where i put the actionsheet is in a provider called Utils and in a promise function :

  readyToRemoveBookmark() {
    return new Promise((resolve, reject) => {
      let actionSheet = this.actionSheetCtrl.create({
        title: 'Êtes-vous sûr ?',
        buttons: [
          {
            text: 'Supprimer',
            role: 'destructive',
            handler: () => {
              resolve();
            }
          },{
            text: 'Annuler',
            role: 'cancel',
            handler: () => {
              reject();
            }
          }
        ]
      });
      actionSheet.present();
    });
  }

And i call this function in a page :

  removeBookmarks() {
    this.utils.readyToRemoveBookmark().then(() => {
      if (this.selectedBookmarks.length) {
        for (let bookmark of this.selectedBookmarks) {
          if (bookmark.type == "folder") {
            this.database.getBookmarks(bookmark.key).then((result) => {
              for (let bookmarkInFolder of result) this.removeBookmark(bookmarkInFolder);
            }, (error) => {
              console.log("ERROR: ", error);
            });
          }
          this.removeBookmark(bookmark);
        }
      }
    });
  }

Here the app.module :

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { AboutPage } from '../pages/about/about';
import { BookmarkPage } from '../pages/bookmark/bookmark';
import { ResourcePage } from "../pages/resource/resource";
import { SafePipe } from "../pipes/safe.pipe";
import { Database } from "../providers/database";
import { AddPage } from "../pages/add/add";
import { Utils } from "../providers/utils";
import { ScNetwork } from "../providers/sc-network";
import { LocalStorage } from "../providers/local-storage";
import { Download } from "../providers/download";
import { FormsModule }   from '@angular/forms';
import { PopoverPage } from "../pages/popover/popover";
import { DownloadPage } from "../pages/download/download";
import { HelpPage } from "../pages/help/help";
import { FavoritePage } from "../pages/favorite/favorite";
import { ScProgressComponent } from "../components/sc-progress/sc-progress";
import { ScTreeListComponent } from "../components/sc-tree-list/sc-tree-list";
import { TransferPage } from "../pages/transfer/transfer";
import { AutoFocusDirective } from "../components/auto-focus/auto-focus";
import { OrderByPipe } from "../pipes/orderBy.pipe";
import { SortableDirective } from "../components/sortable/sortable";
import { ZoomDirective } from "../components/zoom/zoom";
import { HttpModule } from "@angular/http";
import { SQLite } from "@ionic-native/sqlite";
import { StatusBar } from "@ionic-native/status-bar";
import { Toast } from "@ionic-native/toast";
import { File } from '@ionic-native/file';
import { LocalNotifications } from "@ionic-native/local-notifications";
import { Network } from "@ionic-native/network";
import { Transfer } from "@ionic-native/transfer";
import { Zip } from "@ionic-native/zip";
import { AppVersion } from '@ionic-native/app-version';
import { BarcodeScanner } from "@ionic-native/barcode-scanner";
import { FileOpener } from "@ionic-native/file-opener";

@NgModule({
  declarations: [
    MyApp,
    AboutPage,
    BookmarkPage,
    ResourcePage,
    AddPage,
    SafePipe,
    PopoverPage,
    DownloadPage,
    HelpPage,
    FavoritePage,
    ScProgressComponent,
    ScTreeListComponent,
    TransferPage,
    AutoFocusDirective,
    OrderByPipe,
    SortableDirective,
    ZoomDirective
  ],
  imports: [
    BrowserModule,
    HttpModule,
    IonicModule.forRoot(MyApp),
    FormsModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    AboutPage,
    BookmarkPage,
    ResourcePage,
    AddPage,
    PopoverPage,
    DownloadPage,
    HelpPage,
    FavoritePage,
    ScProgressComponent,
    ScTreeListComponent,
    TransferPage
  ],
  providers: [
    Database,
    Utils,
    ScNetwork,
    LocalStorage,
    Download,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    SQLite,
    StatusBar,
    File,
    Toast,
    LocalNotifications,
    Network,
    Transfer,
    Zip,
    AppVersion,
    BarcodeScanner,
    FileOpener
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule {}

Thanks again.


#4

The exacte error is :
main.js:1 ERROR Error: Uncaught (in promise): Error: No component factory found for t. Did you add it to @NgModule.entryComponents?
Error: No component factory found for t. Did you add it to @NgModule.entryComponents?

I have the same error with an Alert in fact …
I don’t have the error if i put the function directly in the component page. So maybe i have something in my provider …
So this is not a bug from Ionic but more probably from my code :wink:


#5

After an update of Ionic 3.1.1, all seems good.
Sorry and thanks again for your time …

PS : how to pass this message resolve ?