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.