Cordova File Plugin

Im using IONIC 2 and trying to use the cordova file plugin from here https://ionicframework.com/docs/v2/native/file/

My goal is to save a file to the device and load it at a later stage.

The issue I’m having right now is that I have installed the plugin but when using this code…

  ionViewDidLoad() {
    const dataDirectory: string = File.dataDirectory;
    File.checkDir(dataDirectory, 'mydir').then(_ => console.log('yay')).catch(err => console.log('boooh'));

  }

I get an error from typescript in my ide saying “Property ‘dataDirectory’ does not exist on type ‘typeof File’”

Check your ionic-native version. See if the problem persists with 2.8.1.

this error occurs if you execute your app on your device?

It will not work in the browser btw.

Thanks for the replies.

@rapropos My ionic-native version is…
"ionic-native": "2.2.11",

@bengtler
I can’t even get to running the app anywhere.

The issue is at compile time.


Cordova CLI: 6.5.0
Ionic Framework Version: 2.1.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v4.2.1
Xcode version: Not installed

Here is an example: http://stackoverflow.com/questions/37890177/ionic2-load-and-save-image-to-device-using-cordova-file-transfer/42635255#42635255