-
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?
Changes from all commits
9c0859d
e979ea8
67d1164
ebb2a94
2660f4c
08cf534
19727c5
925be88
8311b56
dbba4e2
6a93709
6fb2f87
0bf8977
954c32b
318444e
2b7b188
3a30866
1a83529
9c926b4
082bdef
ae805bb
3e77409
32fc888
c3ee323
22165d1
9c6729f
a5069fd
35db01b
16ade0c
a21d5e8
effdaaa
2aeb4fb
20aa15b
872a89f
a2d98da
a180cad
977db91
ff70a52
7628df1
c62cb45
444aeb1
9a5f1cb
b43acd1
45957b4
d954a3d
8cbe764
77848e5
7714f0e
dc6764c
49210d3
5b41def
a4e4db6
c3a34a9
899f1ea
4d23054
c0d4ea8
cc3843f
1e4305e
32c1a4b
f178e08
3139c48
7e46c17
1122ed6
c0b36f1
a55294f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,10 +4,10 @@ sidebar_label: Build Your First App | |
| --- | ||
|
|
||
| <head> | ||
| <title>Build Your First Ionic Mobile App: Angular Development Tutorial</title> | ||
| <title>Build Your First Ionic Mobile App with Angular | Ionic Capacitor Camera</title> | ||
| <meta | ||
| name="description" | ||
| content="Ionic's single codebase builds for any platform using just HTML, CSS, & JavaScript. Develop your first mobile app with our step-by-step Angular tutorial." | ||
| content="This Angular tutorial teaches the fundamentals of Ionic app development by creating a realistic app step-by-step. Learn to run your first Ionic app with Angular." | ||
| /> | ||
| </head> | ||
|
|
||
|
|
@@ -34,11 +34,11 @@ We'll create a Photo Gallery app that offers the ability to take photos with you | |
|
|
||
| Highlights include: | ||
|
|
||
| - One Angular-based codebase that runs on the web, iOS, and Android using Ionic Framework [UI components](https://ionicframework.com/docs/components). | ||
| - One Angular-based codebase that runs on the web, iOS, and Android using Ionic Framework [UI components](../components.md). | ||
brandyscarney marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - Deployed as a native iOS and Android mobile app using [Capacitor](https://capacitorjs.com), Ionic's official native app runtime. | ||
| - Photo Gallery functionality powered by the Capacitor [Camera](https://capacitorjs.com/docs/apis/camera), [Filesystem](https://capacitorjs.com/docs/apis/filesystem), and [Preferences](https://capacitorjs.com/docs/apis/preferences) APIs. | ||
| - Photo Gallery functionality powered by the Capacitor [Camera](../native/camera.md), [Filesystem](../native/filesystem.md), and [Preferences](../native/preferences.md) APIs. | ||
|
|
||
| Find the complete app code referenced in this guide [on GitHub](https://github.com/ionic-team/photo-gallery-capacitor-ng). | ||
| Find the [complete app code](https://github.com/ionic-team/tutorial-photo-gallery-angular) referenced in this guide on GitHub. | ||
|
|
||
| ## Download Required Tools | ||
|
|
||
|
|
@@ -47,9 +47,8 @@ Download and install these right away to ensure an optimal Ionic development exp | |
| - **Node.js** for interacting with the Ionic ecosystem. [Download the LTS version here](https://nodejs.org/en/). | ||
| - **A code editor** for... writing code! We are fans of [Visual Studio Code](https://code.visualstudio.com/). | ||
| - **Command-line interface/terminal (CLI)**: | ||
| - **Windows** users: for the best Ionic experience, we recommend the built-in command line (cmd) or the Powershell | ||
| CLI, running in Administrator mode. | ||
| - **Mac/Linux** users, virtually any terminal will work. | ||
| - **Windows** users: for the best Ionic experience, we recommend the built-in command line (cmd) or the Powershell CLI, running in Administrator mode. | ||
| - **Mac/Linux** users: virtually any terminal will work. | ||
|
|
||
| ## Install Ionic Tooling | ||
|
|
||
|
|
@@ -71,7 +70,7 @@ Consider setting up npm to operate globally without elevated permissions. See [R | |
|
|
||
| ## Create an App | ||
|
|
||
| Next, create an Ionic Angular app that uses the “Tabs” starter template and adds Capacitor for native functionality: | ||
| Next, create an Ionic Angular app that uses the "Tabs" starter template and adds Capacitor for native functionality: | ||
|
|
||
| ```shell | ||
| ionic start photo-gallery tabs --type=angular --capacitor | ||
|
|
@@ -99,7 +98,7 @@ npm install @capacitor/camera @capacitor/preferences @capacitor/filesystem | |
|
|
||
| ### PWA Elements | ||
|
|
||
| Some Capacitor plugins, including the Camera API, provide the web-based functionality and UI via the Ionic [PWA Elements library](https://github.com/ionic-team/ionic-pwa-elements). | ||
| Some Capacitor plugins, including the [Camera API](../native/camera.md), provide the web-based functionality and UI via the Ionic [PWA Elements library](https://github.com/ionic-team/pwa-elements). | ||
|
|
||
| It's a separate dependency, so install it next: | ||
|
|
||
|
|
@@ -109,11 +108,18 @@ npm install @ionic/pwa-elements | |
|
|
||
| Next, import `@ionic/pwa-elements` by editing `src/main.ts`. | ||
|
|
||
| ```tsx | ||
| ```ts | ||
| import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
| import { AppModule } from './app/app.module'; | ||
| // CHANGE: Add the following import | ||
| import { defineCustomElements } from '@ionic/pwa-elements/loader'; | ||
|
|
||
| // Call the element loader before the bootstrapModule/bootstrapApplication call | ||
| // CHANGE: Call the element loader before the `bootstrapModule` call | ||
| defineCustomElements(window); | ||
|
|
||
| platformBrowserDynamic() | ||
| .bootstrapModule(AppModule) | ||
| .catch((err) => console.log(err)); | ||
| ``` | ||
|
|
||
| That’s it! Now for the fun part - let’s see the app in action. | ||
|
|
@@ -128,55 +134,89 @@ ionic serve | |
|
|
||
| And voilà! Your Ionic app is now running in a web browser. Most of your app can be built and tested right in the browser, greatly increasing development and testing speed. | ||
|
|
||
| ## Photo Gallery!!! | ||
| ## Photo Gallery | ||
|
|
||
| There are three tabs. Click on the Tab2 tab. It’s a blank canvas, aka the perfect spot to transform into a Photo Gallery. The Ionic CLI features Live Reload, so when you make changes and save them, the app is updated immediately! | ||
| There are three tabs. Click on the "Tab2" tab. It’s a blank canvas, aka the perfect spot to transform into a Photo Gallery. The Ionic CLI features Live Reload, so when you make changes and save them, the app is updated immediately! | ||
|
|
||
|  | ||
|
|
||
| Open the photo-gallery app folder in your code editor of choice, then navigate to `/src/app/tab2/tab2.page.html`. We see: | ||
| Open `/src/app/tab2/tab2.page.html`. We see: | ||
|
|
||
| ```html | ||
| <ion-header> | ||
| <ion-header [translucent]="true"> | ||
| <ion-toolbar> | ||
| <ion-title>Tab 2</ion-title> | ||
| <ion-title> Tab 2 </ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
|
|
||
| <ion-content> | ||
| <ion-content [fullscreen]="true"> | ||
| <ion-header collapse="condense"> | ||
| <ion-toolbar> | ||
| <ion-title size="large">Tab 2</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
|
|
||
| <app-explore-container name="Tab 2 page"></app-explore-container> | ||
| </ion-content> | ||
| ``` | ||
|
|
||
| `ion-header` represents the top navigation and toolbar, with "Tab 2" as the title (there are two of them due to iOS [Collapsible Large Title](https://ionicframework.com/docs/api/title#collapsible-large-titles) support). Rename both `ion-title` elements to: | ||
| `ion-header` represents the top navigation and toolbar, with "Tab 2" as the title (there are two of them due to iOS [Collapsible Large Title](../api/title.md#collapsible-large-titles) support). Rename both `ion-title` elements to: | ||
brandyscarney marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```html | ||
| <ion-title>Photo Gallery</ion-title> | ||
| ``` | ||
|
|
||
| We put the visual aspects of our app into `<ion-content>`. In this case, it’s where we’ll add a button that opens the device’s camera as well as displays the image captured by the camera. Start by adding a [floating action button](https://ionicframework.com/docs/api/fab) (FAB) to the bottom of the page and set the camera image as the icon. | ||
| We put the visual aspects of our app into `<ion-content>`. In this case, it’s where we’ll add a button that opens the device’s camera as well as displays the image captured by the camera. Start by adding a [floating action button](../api/fab.md) (FAB) to the bottom of the page and set the camera image as the icon. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than changing these paths to relative links like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I do that, then we wouldn't be able to directly jump to those files using an IDE. I get a warning that the file doesn't exist when I CMD+Left_Mouse_Click |
||
|
|
||
| ```html | ||
| <ion-header [translucent]="true"> | ||
| <ion-toolbar> | ||
| <ion-title>Photo Gallery</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
|
|
||
| <ion-content> | ||
| <ion-header collapse="condense"> | ||
| <ion-toolbar> | ||
| <ion-title size="large">Photo Gallery</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
|
|
||
| <!-- CHANGE: Add the floating action button. --> | ||
| <ion-fab vertical="bottom" horizontal="center" slot="fixed"> | ||
| <ion-fab-button> | ||
| <ion-icon name="camera"></ion-icon> | ||
| </ion-fab-button> | ||
| </ion-fab> | ||
|
|
||
| <!-- CHANGE: Remove or comment out `app-explore-container`. --> | ||
| <!-- <app-explore-container name="Tab 2 page"></app-explore-container> --> | ||
| </ion-content> | ||
| ``` | ||
|
|
||
| Next, open `src/app/tabs/tabs.page.html`. Change the label to “Photos” and the icon name to “images”: | ||
| Next, open `src/app/tabs/tabs.page.html`. Change the label to "Photos" and the `ellipse` icon to `images` for the middle tab button. | ||
|
|
||
| ```html | ||
| <ion-tab-button tab="tab2"> | ||
| <ion-icon name="images"></ion-icon> | ||
| <ion-label>Photos</ion-label> | ||
| </ion-tab-button> | ||
| <ion-tabs> | ||
| <ion-tab-bar slot="bottom"> | ||
| <ion-tab-button tab="tab1" href="/tabs/tab1"> | ||
| <ion-icon aria-hidden="true" name="triangle"></ion-icon> | ||
| <ion-label>Tab 1</ion-label> | ||
| </ion-tab-button> | ||
|
|
||
| <ion-tab-button tab="tab2" href="/tabs/tab2"> | ||
| <!-- CHANGE: Update icon. --> | ||
| <ion-icon aria-hidden="true" name="images"></ion-icon> | ||
| <!-- CHANGE: Update label. --> | ||
| <ion-label>Photos</ion-label> | ||
| </ion-tab-button> | ||
|
|
||
| <ion-tab-button tab="tab3" href="/tabs/tab3"> | ||
| <ion-icon aria-hidden="true" name="square"></ion-icon> | ||
| <ion-label>Tab 3</ion-label> | ||
| </ion-tab-button> | ||
| </ion-tab-bar> | ||
| </ion-tabs> | ||
| ``` | ||
|
|
||
| Save all changes to see them automatically applied in the browser. That’s just the start of all the cool things we can do with Ionic. Up next, implement camera taking functionality on the web, then build it for iOS and Android. | ||
| That’s just the start of all the cool things we can do with Ionic. Up next, implement camera taking functionality on the web, then build it for iOS and Android. | ||
Uh oh!
There was an error while loading. Please reload this page.