I am currently working with Ionic, Angular, and Typescript, attempting to dynamically set the value of a location based on the parameter passed from a method.
Here is the relevant code snippet:
async fileWrite(location) {
try {
const result = await Filesystem.writeFile({
path: `test.txt`,
data: `This is a test`,
directory: location,
encoding: FilesystemEncoding.UTF8
});
alert('Wrote file' + result);
} catch (e) {
alert('Unable to write file' + e);
}
}
As you can see:
directory: location,
The 'location' variable contains the necessary value.
I am passing it as follows:
<ion-button (click)="fileWrite('FilesystemDirectory.Cache')">FileWrite to Cache</ion-button>
However, for some reason, it is not being recognized as a variable.
How can I address this issue?