Skip to content

Commit a0f9248

Browse files
docs(angular): fix indentation in 5-adding-mobile.md (#2855)
* docs: fix indentation in 5-adding-mobile.md * Also change in v7 docs --------- Co-authored-by: Shawn Taylor <shawn@ionic.io>
1 parent ec01f80 commit a0f9248

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

docs/angular/your-first-app/5-adding-mobile.md

+27-27
Original file line numberDiff line numberDiff line change
@@ -57,35 +57,35 @@ Next, update the `savePicture()` method. When running on mobile, set `filepath`
5757

5858
```tsx
5959
// Save picture to file on device
60-
private async savePicture(photo: Photo) {
61-
// Convert photo to base64 format, required by Filesystem API to save
62-
const base64Data = await this.readAsBase64(photo);
63-
64-
// Write the file to the data directory
65-
const fileName = new Date().getTime() + '.jpeg';
66-
const savedFile = await Filesystem.writeFile({
67-
path: fileName,
68-
data: base64Data,
69-
directory: Directory.Data
70-
});
60+
private async savePicture(photo: Photo) {
61+
// Convert photo to base64 format, required by Filesystem API to save
62+
const base64Data = await this.readAsBase64(photo);
63+
64+
// Write the file to the data directory
65+
const fileName = new Date().getTime() + '.jpeg';
66+
const savedFile = await Filesystem.writeFile({
67+
path: fileName,
68+
data: base64Data,
69+
directory: Directory.Data
70+
});
7171

72-
if (this.platform.is('hybrid')) {
73-
// Display the new image by rewriting the 'file://' path to HTTP
74-
// Details: https://ionicframework.com/docs/building/webview#file-protocol
75-
return {
76-
filepath: savedFile.uri,
77-
webviewPath: Capacitor.convertFileSrc(savedFile.uri),
78-
};
79-
}
80-
else {
81-
// Use webPath to display the new image instead of base64 since it's
82-
// already loaded into memory
83-
return {
84-
filepath: fileName,
85-
webviewPath: photo.webPath
86-
};
87-
}
72+
if (this.platform.is('hybrid')) {
73+
// Display the new image by rewriting the 'file://' path to HTTP
74+
// Details: https://ionicframework.com/docs/building/webview#file-protocol
75+
return {
76+
filepath: savedFile.uri,
77+
webviewPath: Capacitor.convertFileSrc(savedFile.uri),
78+
};
8879
}
80+
else {
81+
// Use webPath to display the new image instead of base64 since it's
82+
// already loaded into memory
83+
return {
84+
filepath: fileName,
85+
webviewPath: photo.webPath
86+
};
87+
}
88+
}
8989
```
9090

9191
Next, head back over to the `loadSaved()` function we implemented for the web earlier. On mobile, we can directly set the source of an image tag - `<img src="x" />` - to each photo file on the Filesystem, displaying them automatically. Thus, only the web requires reading each image from the Filesystem into base64 format. Update this function to add an _if statement_ around the Filesystem code:

versioned_docs/version-v6/angular/your-first-app/5-adding-mobile.md

+27-27
Original file line numberDiff line numberDiff line change
@@ -57,35 +57,35 @@ Next, update the `savePicture()` method. When running on mobile, set `filepath`
5757

5858
```tsx
5959
// Save picture to file on device
60-
private async savePicture(photo: Photo) {
61-
// Convert photo to base64 format, required by Filesystem API to save
62-
const base64Data = await this.readAsBase64(photo);
63-
64-
// Write the file to the data directory
65-
const fileName = new Date().getTime() + '.jpeg';
66-
const savedFile = await Filesystem.writeFile({
67-
path: fileName,
68-
data: base64Data,
69-
directory: Directory.Data
70-
});
60+
private async savePicture(photo: Photo) {
61+
// Convert photo to base64 format, required by Filesystem API to save
62+
const base64Data = await this.readAsBase64(photo);
63+
64+
// Write the file to the data directory
65+
const fileName = new Date().getTime() + '.jpeg';
66+
const savedFile = await Filesystem.writeFile({
67+
path: fileName,
68+
data: base64Data,
69+
directory: Directory.Data
70+
});
7171

72-
if (this.platform.is('hybrid')) {
73-
// Display the new image by rewriting the 'file://' path to HTTP
74-
// Details: https://ionicframework.com/docs/building/webview#file-protocol
75-
return {
76-
filepath: savedFile.uri,
77-
webviewPath: Capacitor.convertFileSrc(savedFile.uri),
78-
};
79-
}
80-
else {
81-
// Use webPath to display the new image instead of base64 since it's
82-
// already loaded into memory
83-
return {
84-
filepath: fileName,
85-
webviewPath: photo.webPath
86-
};
87-
}
72+
if (this.platform.is('hybrid')) {
73+
// Display the new image by rewriting the 'file://' path to HTTP
74+
// Details: https://ionicframework.com/docs/building/webview#file-protocol
75+
return {
76+
filepath: savedFile.uri,
77+
webviewPath: Capacitor.convertFileSrc(savedFile.uri),
78+
};
8879
}
80+
else {
81+
// Use webPath to display the new image instead of base64 since it's
82+
// already loaded into memory
83+
return {
84+
filepath: fileName,
85+
webviewPath: photo.webPath
86+
};
87+
}
88+
}
8989
```
9090

9191
Next, head back over to the `loadSaved()` function we implemented for the web earlier. On mobile, we can directly set the source of an image tag - `<img src="x" />` - to each photo file on the Filesystem, displaying them automatically. Thus, only the web requires reading each image from the Filesystem into base64 format. Update this function to add an _if statement_ around the Filesystem code:

0 commit comments

Comments
 (0)