Skip to content

Commit ac9c2ef

Browse files
docs(quickstart): fix JavaScript initialization and update guides to include full file paths (#4322)
Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
1 parent 62936d6 commit ac9c2ef

File tree

9 files changed

+365
-365
lines changed

9 files changed

+365
-365
lines changed

docs/angular/quickstart.md

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,24 @@ 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

7678
Let's walk through these files to understand the app's structure.
@@ -79,7 +81,7 @@ Let's walk through these files to understand the app's structure.
7981

8082
The root of your app is defined in `app.component.ts`:
8183

82-
```ts
84+
```ts title="src/app/app.component.ts"
8385
import { Component } from '@angular/core';
8486
import { IonApp, IonRouterOutlet } from '@ionic/angular/standalone';
8587

@@ -95,7 +97,7 @@ export class AppComponent {
9597

9698
And its template in `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>
@@ -107,7 +109,7 @@ This sets up the root of your application, using Ionic's `ion-app` and `ion-rout
107109

108110
Routes are defined in `app.routes.ts`:
109111

110-
```ts
112+
```ts title="src/app/app.routes.ts"
111113
import { Routes } from '@angular/router';
112114

113115
export 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 `home.page.ts`, imports the Ionic components it uses:
131133

132-
```ts
134+
```ts title="src/app/home/home.page.ts"
133135
import { Component } from '@angular/core';
134136
import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
135137

@@ -146,7 +148,7 @@ export class HomePage {
146148

147149
And the template, in the `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>
@@ -170,17 +172,17 @@ And the template, in the `home.page.html` file, uses those components:
170172
</ion-content>
171173
```
172174

173-
This creates a page with a header and scrollable content area. The second header shows a [collapsible large title](/docs/api/title#collapsible-large-titles) that displays when at the top of the content, then condenses to show the smaller title in the first header when scrolling down.
175+
This creates a page with a header and scrollable content area. The second header shows a [collapsible large title](/docs/api/title.md#collapsible-large-titles) that displays when at the top of the content, then condenses to show the smaller title in the first header when scrolling down.
174176

175177
:::tip Learn More
176-
For detailed information about Ionic layout components, see the [Header](/docs/api/header), [Toolbar](/docs/api/toolbar), [Title](/docs/api/title), and [Content](/docs/api/content) documentation.
178+
For detailed information about Ionic layout components, see the [Header](/docs/api/header.md), [Toolbar](/docs/api/toolbar.md), [Title](/docs/api/title.md), and [Content](/docs/api/content.md) documentation.
177179
:::
178180

179181
## Add an Ionic Component
180182

181-
You 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`:
183+
You can enhance your Home page with more Ionic UI components. For example, add a [Button](/docs/api/button.md) 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

@@ -190,7 +192,7 @@ You can enhance your Home page with more Ionic UI components. For example, add a
190192

191193
Then, import the `IonButton` component in `home.page.ts`:
192194

193-
```ts
195+
```ts title="src/app/home/home.page.ts"
194196
import { IonButton, IonContent, IonHeader, IonTitle, IonToolbar } from '@ionic/angular/standalone';
195197

196198
@Component({
@@ -209,9 +211,9 @@ ionic generate page new
209211

210212
A route will be automatically added to `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 `new.page.html`, you can add a [Back Button](/docs/api/back-button.md) to the [Toolbar](/docs/api/toolbar.md):
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 `new.page.ts`:
226228

227-
```ts
229+
```ts title="src/app/new/new.page.ts"
228230
import { 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 `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 `home.page.ts`:
247249

248-
```ts
250+
```ts title="src/app/home/home.page.ts"
249251
import { RouterLink } from '@angular/router';
250252

251253
@Component({
@@ -255,14 +257,14 @@ import { RouterLink } from '@angular/router';
255257
```
256258

257259
:::info
258-
Navigating can also be performed using Angular's Router service. See the [Angular Navigation documentation](/docs/angular/navigation#navigating-to-different-routes) for more information.
260+
Navigating can also be performed using Angular's Router service. See the [Angular Navigation documentation](/docs/angular/navigation.md#navigating-to-different-routes) for more information.
259261
:::
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 `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 `new.page.ts`:
275277

276-
```ts
278+
```ts title="src/app/new/new.page.ts"
277279
// ...existing imports...
278280
import { IonBackButton, IonButtons, IonContent, IonHeader, IonIcon, IonTitle, IonToolbar } from '@ionic/angular/standalone';
279281
import { addIcons } from 'ionicons';
@@ -287,7 +289,7 @@ import { heart, logoIonic } from 'ionicons/icons';
287289

288290
Then, update the constructor of the page to use `addIcons`:
289291

290-
```ts
292+
```ts title="src/app/new/new.page.ts"
291293
export class NewPage implements OnInit {
292294
constructor() {
293295
addIcons({ heart, logoIonic });
@@ -299,15 +301,15 @@ export class NewPage implements OnInit {
299301

300302
Alternatively, you can register icons in `app.component.ts` to use them throughout your app.
301303

302-
For more information, see the [Icon documentation](/docs/api/icon) and the [Ionicons documentation](https://ionic.io/ionicons/).
304+
For more information, see the [Icon documentation](/docs/api/icon.md) and the [Ionicons documentation](https://ionic.io/ionicons/).
303305

304306
## Call Component Methods
305307

306308
Let'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 `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

332334
In 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"
335337
import { Component, OnInit, ViewChild } from '@angular/core';
336338
import {
337339
IonBackButton,
@@ -385,7 +387,7 @@ To call methods on Ionic components:
385387
1. Create a `ViewChild` reference for the component
386388
2. Call the method directly on the component instance
387389

388-
You can find available methods for each component in the [Methods](/docs/api/content#methods) section of their API documentation.
390+
You can find available methods for each component in the [Methods](/docs/api/content.md#methods) section of their API documentation.
389391

390392
## Run on a Device
391393

0 commit comments

Comments
 (0)