Skip to content

Conversation

@soundproofboot
Copy link
Contributor

@soundproofboot soundproofboot commented Jun 17, 2025

resolves #2082

Changes:

  • Update code blocks and text for the Angular Photo App tutorial to show additional context for each step with comments to indicate new lines.

Preview

@soundproofboot soundproofboot requested a review from a team as a code owner June 17, 2025 18:22
@soundproofboot soundproofboot requested a review from gnbm June 17, 2025 18:22
@vercel
Copy link

vercel bot commented Jun 17, 2025

@soundproofboot is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Jun 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
ionic-docs Ready Ready Preview Comment Oct 31, 2025 0:38am

@brandyscarney brandyscarney changed the title docs(angular): "Your First App" tutorial should show complete code context(#2082) docs(angular): show complete code context in the "Your First App" tutorial Jun 23, 2025
@brandyscarney brandyscarney requested review from thetaPC and removed request for gnbm June 23, 2025 15:28
Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also update Page 7 Live reload to include more complete code.

Fixed typo in the congratulations message regarding user devices.
Copy link
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thetaPC I left some comments with requested changes. In many of these cases the code appears in more than the one place I commented. Additionally, we should probably make the same changes across all 3 PRs (React & Vue).

The only major change I would request is to convert this to follow a Standalone app.

Note: I did not do a thorough code review due to the possibility of converting this to Standalone. I will do that after all requested changes are made.


<ion-grid>
<ion-row>
<ion-col size="6" *ngFor="let photo of photoService.photos; index as position">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not be using ngFor, the new way is to use @for: https://angular.dev/api/core/@for

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thetaPC You can ignore this feedback too - let's just do it on the standalone conversion.

Copy link
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through the process of creating an app following these guides and only ran into a couple of issues which I requested changes on. Any changes made for v8 also need to be made for v7 but I didn't request in both places. 👍

Comment on lines +45 to +47
import { Preferences } from '@capacitor/preferences';

export class PhotoService {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { Preferences } from '@capacitor/preferences';
export class PhotoService {
import { Preferences } from '@capacitor/preferences';
@Injectable({
providedIn: 'root'
})
export class PhotoService {

Without this here, I see the following error when I go to tab 2:

Image

It seems confusing to not include it when the imports are included.

```

On mobile (coming up next!), we can directly set the source of an image tag - `<img src="http://github.com/x" />` - to each photo file on the Filesystem, displaying them automatically. On the web, however, we must read each image from the Filesystem into base64 format, using a new `base64` property on the `Photo` object. This is because the Filesystem API uses [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) under the hood. Below is the code you need to add in the `loadSaved()` function you just added:
`photo.service.ts` should now look like this:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code below this does not match what is actually in the file. The loadSaved function is missing what we added in the previous step.

Comment on lines +83 to +94
// CHANGE: Display the photo by reading into base64 format
for (let photo of this.photos) {
// Read each saved photo's data from the Filesystem
const file = await Filesystem.file({
path: photo.filepath,
directory: Directory.Data,
});

// Web platform only: Load the photo as base64 data
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// CHANGE: Display the photo by reading into base64 format
for (let photo of this.photos) {
// Read each saved photo's data from the Filesystem
const file = await Filesystem.file({
path: photo.filepath,
directory: Directory.Data,
});
// Web platform only: Load the photo as base64 data
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
}
}
// CHANGE: Display the photo by reading into base64 format
for (let photo of this.photos) {
// Read each saved photo's data from the Filesystem
const readFile = await Filesystem.readFile({
path: photo.filepath,
directory: Directory.Data,
});
// Web platform only: Load the photo as base64 data
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
}
}

This code errors.

for (let photo of this.photos) {
// Read each saved photo's data from the Filesystem
const readFile = await Filesystem.readFile({
const file = await Filesystem.file({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const file = await Filesystem.file({
const readFile = await Filesystem.readFile({

This code throws an error

Image


// Web platform only: Load the photo as base64 data
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;

See above comment

Comment on lines +273 to +278
const file = await Filesystem.file({
path: photo.filepath,
directory: Directory.Data,
});
// Web platform only: Load the photo as base64 data
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const file = await Filesystem.file({
path: photo.filepath,
directory: Directory.Data,
});
// Web platform only: Load the photo as base64 data
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
const readFile = await Filesystem.readFile({
path: photo.filepath,
directory: Directory.Data,
});
// Web platform only: Load the photo as base64 data
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;

See above comment

});

// Delete photo file from filesystem
const filename = photo.filepath.substr(photo.filepath.lastIndexOf('/') + 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const filename = photo.filepath.substr(photo.filepath.lastIndexOf('/') + 1);
const filename = photo.filepath.slice(photo.filepath.lastIndexOf('/') + 1);

substr is deprecated - optional change since it is in the final code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep this guide since Appflow has been discontinued? Maybe update it to point to other offerings?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a suggestion to where to point it to? I would rather us not mention Appflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Your First App" tutorial should show complete code context - Angular

3 participants