Hello,
I am trying to use File Plugin (File API Plugin for Read and Write File Access on Devices) to open a local file in my project (the file is located in assets folder).
app.module.ts
(...)
// File Plugin
import { File } from '@ionic-native/file/ngx';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
File],
bootstrap: [AppComponent],
})
export class AppModule {}
tab1.page.ts
import { File } from '@ionic-native/file/ngx';
(...)
constructor(
(...)
private file: File) {}
openLocal(){
let filePath = this.file.applicationDirectory';
console.log(filePath);
}
tab1.page.html
(...)
<ion-button expand="full" (click)="openLocal()">Open PDF</ion-button>
(....)
Console returns NULL for “filePath” (this.file.applicationDirectory’).
I am using:
Ionic CLI : 5.4.16
Ionic Framework : @ionic/angular 6.0.1
@angular-devkit/build-angular : 13.0.4
@angular-devkit/schematics : 13.0.4
@angular/cli : 13.0.4
@ionic/angular-toolkit : 5.0.3
Capacitor:
Capacitor CLI : 3.3.3
@capacitor/core : 3.3.3
Utility:
cordova-res (update available: 0.15.4) : 0.15.3
native-run : 1.5.0
System:
NodeJS : v16.13.1
npm : 8.1.2
OS : macOS Monterey
I will be grateful for your comments.
3 posts - 2 participants