@@ -55,31 +55,33 @@ After running `ionic serve`, your project will open in the browser.
5555
5656## Explore the Project Structure
5757
58- Your new app's ` src/app ` directory will look like this:
58+ Your new app's directory will look like this:
5959
6060``` shell
61- ├── app.component.html
62- ├── app.component.scss
63- ├── app.component.ts
64- ├── app.routes.ts
65- └── home/
66- ├── home.page.html
67- ├── home.page.scss
68- ├── home.page.spec.ts
69- └── home.page.ts
61+ └── src/
62+ └── app
63+ ├── app.component.html
64+ ├── app.component.scss
65+ ├── app.component.ts
66+ ├── app.routes.ts
67+ └── home/
68+ ├── home.page.html
69+ ├── home.page.scss
70+ ├── home.page.spec.ts
71+ └── home.page.ts
7072```
7173
7274::: info
73- All file paths in the examples below are relative to the ` src/app/ ` directory.
75+ All file paths in the examples below are relative to the project root directory.
7476:::
7577
7678Let's walk through these files to understand the app's structure.
7779
7880## View the App Component
7981
80- The root of your app is defined in ` app.component.ts ` :
82+ The root of your app is defined in ` src/app/ app.component.ts` :
8183
82- ``` ts
84+ ``` ts title="src/app/app.component.ts"
8385import { Component } from ' @angular/core' ;
8486import { IonApp , IonRouterOutlet } from ' @ionic/angular/standalone' ;
8587
@@ -93,9 +95,9 @@ export class AppComponent {
9395}
9496```
9597
96- And its template in ` app.component.html ` :
98+ And its template in ` src/app/ app.component.html` :
9799
98- ``` html
100+ ``` html title="src/app/app.component.html"
99101<ion-app >
100102 <ion-router-outlet ></ion-router-outlet >
101103</ion-app >
@@ -105,9 +107,9 @@ This sets up the root of your application, using Ionic's `ion-app` and `ion-rout
105107
106108## View Routes
107109
108- Routes are defined in ` app.routes.ts ` :
110+ Routes are defined in ` src/app/ app.routes.ts` :
109111
110- ``` ts
112+ ``` ts title="src/app/app.routes.ts"
111113import { Routes } from ' @angular/router' ;
112114
113115export const routes: Routes = [
@@ -127,9 +129,9 @@ When you visit the root URL (`/`), the `HomePage` component will be loaded.
127129
128130## View the Home Page
129131
130- The Home page component, defined in ` home/home.page.ts ` , imports the Ionic components it uses:
132+ The Home page component, defined in ` src/app/ home/home.page.ts` , imports the Ionic components it uses:
131133
132- ``` ts
134+ ``` ts title="src/app/home/home.page.ts"
133135import { Component } from ' @angular/core' ;
134136import { IonHeader , IonToolbar , IonTitle , IonContent } from ' @ionic/angular/standalone' ;
135137
@@ -144,9 +146,9 @@ export class HomePage {
144146}
145147```
146148
147- And the template, in the ` home.page.html ` file, uses those components:
149+ And the template, in the ` src/app/home/ home.page.html` file, uses those components:
148150
149- ``` html
151+ ``` html title="src/app/home/home.page.html"
150152<ion-header [translucent] =" true" >
151153 <ion-toolbar >
152154 <ion-title > Blank </ion-title >
@@ -180,17 +182,17 @@ For detailed information about Ionic layout components, see the [Header](/docs/a
180182
181183You can enhance your Home page with more Ionic UI components. For example, add a [ Button] ( /docs/api/button ) at the end of the ` ion-content ` :
182184
183- ``` html
185+ ``` html title="src/app/home/home.page.html"
184186<ion-content >
185187 <!-- existing content -->
186188
187189 <ion-button >Navigate</ion-button >
188190</ion-content >
189191```
190192
191- Then, import the ` IonButton ` component in ` home.page.ts ` :
193+ Then, import the ` IonButton ` component in ` src/app/home/ home.page.ts` :
192194
193- ``` ts
195+ ``` ts title="src/app/home/home.page.ts"
194196import { IonButton , IonContent , IonHeader , IonTitle , IonToolbar } from ' @ionic/angular/standalone' ;
195197
196198@Component ({
@@ -207,11 +209,11 @@ To add a new page, generate it with the CLI:
207209ionic generate page new
208210```
209211
210- A route will be automatically added to ` app.routes.ts ` .
212+ A route will be automatically added to ` src/app/ app.routes.ts` .
211213
212- In your ` new/new.page.html ` , you can add a [ Back Button] ( /docs/api/back-button ) to the [ Toolbar] ( /docs/api/toolbar ) :
214+ In ` src/app/ new/new.page.html` , you can add a [ Back Button] ( /docs/api/back-button ) to the [ Toolbar] ( /docs/api/toolbar ) :
213215
214- ``` html
216+ ``` html title="src/app/new/new.page.html"
215217<ion-header [translucent] =" true" >
216218 <ion-toolbar >
217219 <ion-buttons slot =" start" >
@@ -222,9 +224,9 @@ In your `new/new.page.html`, you can add a [Back Button](/docs/api/back-button)
222224</ion-header >
223225```
224226
225- And import ` IonBackButton ` and ` IonButtons ` in ` new/new.page.ts ` :
227+ And import ` IonBackButton ` and ` IonButtons ` in ` src/app/ new/new.page.ts` :
226228
227- ``` ts
229+ ``` ts title="src/app/new/new.page.ts"
228230import { IonBackButton , IonButtons , IonContent , IonHeader , IonTitle , IonToolbar } from ' @ionic/angular/standalone' ;
229231
230232@Component ({
@@ -237,15 +239,15 @@ The `ion-back-button` will automatically handle navigation back to the previous
237239
238240## Navigate to the New Page
239241
240- To navigate to the new page, update the button in ` home/home.page.html ` :
242+ To navigate to the new page, update the button in ` src/app/ home/home.page.html` :
241243
242- ``` html
244+ ``` html title="src/app/home/home.page.html"
243245<ion-button [routerLink] =" ['/new']" >Navigate</ion-button >
244246```
245247
246- Then, import ` RouterLink ` in ` home/home.page.ts ` :
248+ Then, import ` RouterLink ` in ` src/app/ home/home.page.ts` :
247249
248- ``` ts
250+ ``` ts title="src/app/home/home.page.ts"
249251import { RouterLink } from ' @angular/router' ;
250252
251253@Component ({
@@ -260,9 +262,9 @@ Navigating can also be performed using Angular's Router service. See the [Angula
260262
261263## Add Icons to the New Page
262264
263- Ionic Angular comes with [ Ionicons] ( https://ionic.io/ionicons/ ) pre-installed. You can use any icon by setting the ` name ` property on the ` ion-icon ` component. Add the following icons to ` new/new.page.html ` :
265+ Ionic Angular comes with [ Ionicons] ( https://ionic.io/ionicons/ ) pre-installed. You can use any icon by setting the ` name ` property on the ` ion-icon ` component. Add the following icons to ` src/app/ new/new.page.html` :
264266
265- ``` html
267+ ``` html title="src/app/new/new.page.html"
266268<ion-content >
267269 <!-- existing content -->
268270
@@ -271,9 +273,9 @@ Ionic Angular comes with [Ionicons](https://ionic.io/ionicons/) pre-installed. Y
271273</ion-content >
272274```
273275
274- You'll also need to import and register these icons in ` new/new.page.ts ` :
276+ You'll also need to import and register these icons in ` src/app/ new/new.page.ts` :
275277
276- ``` ts
278+ ``` ts title="src/app/new/new.page.ts"
277279// ...existing imports...
278280import { IonBackButton , IonButtons , IonContent , IonHeader , IonIcon , IonTitle , IonToolbar } from ' @ionic/angular/standalone' ;
279281import { addIcons } from ' ionicons' ;
@@ -287,7 +289,7 @@ import { heart, logoIonic } from 'ionicons/icons';
287289
288290Then, update the constructor of the page to use ` addIcons ` :
289291
290- ``` ts
292+ ``` ts title="src/app/new/new.page.ts"
291293export class NewPage implements OnInit {
292294 constructor () {
293295 addIcons ({ heart , logoIonic });
@@ -297,17 +299,17 @@ export class NewPage implements OnInit {
297299}
298300```
299301
300- Alternatively, you can register icons in ` app.component.ts ` to use them throughout your app.
302+ Alternatively, you can register icons in ` src/app/ app.component.ts` to use them throughout your app.
301303
302304For more information, see the [ Icon documentation] ( /docs/api/icon ) and the [ Ionicons documentation] ( https://ionic.io/ionicons/ ) .
303305
304306## Call Component Methods
305307
306308Let's add a button that can scroll the content area to the bottom.
307309
308- Update the ` ion-content ` in your ` new/new.page.html ` to include a button and some items after the existing icons:
310+ Update the ` ion-content ` in your ` src/app/ new/new.page.html` to include a button and some items after the existing icons:
309311
310- ``` html
312+ ``` html title="src/app/new/new.page.html"
311313<ion-content [fullscreen] =" true" #content >
312314 <ion-header collapse =" condense" >
313315 <ion-toolbar >
@@ -331,7 +333,7 @@ Update the `ion-content` in your `new/new.page.html` to include a button and som
331333
332334In the component, add the ` ViewChild ` import, the new component imports and define the ` scrollToBottom ` function:
333335
334- ``` ts
336+ ``` ts title="src/app/new/new.page.ts"
335337import { Component , OnInit , ViewChild } from ' @angular/core' ;
336338import {
337339 IonBackButton ,
0 commit comments