-
Notifications
You must be signed in to change notification settings - Fork 3.2k
docs(angular): show complete code context in the "Your First App" tutorial #4157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
docs(angular): show complete code context in the "Your First App" tutorial #4157
Conversation
…t ngFor in 2-taking-photos.md
…ck to 3-saving-photos.md
…-loading-photos.md
|
@soundproofboot is attempting to deploy a commit to the Ionic Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this 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.
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Co-authored-by: Maria Hutt <[email protected]>
Fixed typo in the congratulations message regarding user devices.
There was a problem hiding this 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"> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Co-authored-by: Brandy Smith <[email protected]>
Co-authored-by: Brandy Smith <[email protected]>
There was a problem hiding this 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. 👍
| import { Preferences } from '@capacitor/preferences'; | ||
|
|
||
| export class PhotoService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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:
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: |
There was a problem hiding this comment.
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.
| // 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}`; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // 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({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| // 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}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| photo.webviewPath = `data:image/jpeg;base64,${file.data}`; | |
| photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`; |
See above comment
| 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}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.

resolves #2082
Changes:
Preview