Skip to content

Commit 4dd1d4c

Browse files
committed
feat: add component outputs documentation for Angular
- Introduced new documentation for the component outputs feature in Angular. - Provided detailed instructions for implementing output in the AlertBanner component. - Included examples for integrating output with TaskList and TaskForm components in both English and German.
1 parent 509d1e7 commit 4dd1d4c

File tree

3 files changed

+50
-38
lines changed

3 files changed

+50
-38
lines changed

src/content/docs/de/reusable-components/component-output.mdx renamed to src/content/docs/de/reusable-components/component-outputs.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Component output
3-
description: Component output
2+
title: Component outputs
3+
description: Component outputs
44
course: angular-20
5-
slug: "reusable-components-component-output"
5+
slug: "reusable-components-component-outputs"
66
---
77

88
import { Steps } from '@astrojs/starlight/components';

src/content/docs/en/reusable-components/component-output.mdx renamed to src/content/docs/en/reusable-components/component-outputs.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Component output
3-
description: Component output
2+
title: Component outputs
3+
description: Component outputs
44
course: angular-20
5-
slug: "reusable-components-component-output"
5+
slug: "reusable-components-component-outputs"
66
---
77

88
import { Steps } from '@astrojs/starlight/components';
Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
2-
title: Component output
3-
description: Component output
2+
title: Component outputs
3+
description: Component outputs
44
course: angular-20
5-
slug: "reusable-components-component-output"
5+
slug: "reusable-components-component-outputs"
66
---
77

8-
import { Steps } from '@astrojs/starlight/components';
8+
import { Steps } from "@astrojs/starlight/components";
99
import NotificationCard from "../../../../components/ui/NotificationCard";
1010

1111
# Component output
1212

13-
One key feature of reusable components is to notify the parent component that an action has been performed.
13+
One key feature of reusable components is to notify the parent component that an action has been performed.
1414
In the `AlertBanner` component, we want to add a button, triggering a different action based on its usage:
1515

1616
- in the `TaskList` component, we want to call a function to delete all tasks
@@ -26,49 +26,61 @@ To do so, we'll use the `output` feature of Angular.
2626

2727
1. Update the `AlertBanner` class:
2828

29-
```typescript
30-
import { output } from '@angular/core';
29+
```typescript
30+
import { output } from "@angular/core";
3131

32-
onSubmit = output<void>();
33-
```
32+
onSubmit = output<void>();
33+
```
3434

3535
2. Update the template of `alert-banner.html` file:
3636

37-
```html
38-
<button class="btn"
39-
[class.btn-info]="type() ? type() === 'info' : false"
40-
[class.btn-error]="type() ? type() === 'error' : false"
41-
(click)="onSubmit.emit()">Proceed</button>
42-
```
37+
```html
38+
<button
39+
class="btn"
40+
[class.btn-info]="type() ? type() === 'info' : false"
41+
[class.btn-error]="type() ? type() === 'error' : false"
42+
(click)="onSubmit.emit()"
43+
>
44+
Proceed
45+
</button>
46+
```
4347

4448
3. Update the `TaskList` class:
4549

46-
```typescript
47-
deleteAllTasks() {
48-
// TODO: delete all tasks
49-
}
50-
```
50+
```typescript
51+
deleteAllTasks() {
52+
// TODO: delete all tasks
53+
}
54+
```
5155

5256
4. Update the template of `task-list.html` file:
5357

54-
```html
55-
<app-alert-banner message="Do you really want to delete all tasks?" type="error" (onSubmit)="deleteAllTasks()"/>
56-
```
58+
```html
59+
<app-alert-banner
60+
message="Do you really want to delete all tasks?"
61+
type="error"
62+
(onSubmit)="deleteAllTasks()"
63+
/>
64+
```
5765

5866
5. Update the `TaskForm` class:
5967

60-
```typescript
61-
preFillForm() {
62-
// TODO: pre fill the form with basic information
63-
}
64-
```
68+
```typescript
69+
preFillForm() {
70+
// TODO: pre fill the form with basic information
71+
}
72+
```
6573

6674
6. Update the template of `task-form.html` file:
6775

68-
```html
69-
<app-alert-banner message="Do you want to prefill Form?" type="info" (onSubmit)="preFillForm()" />
70-
```
76+
```html
77+
<app-alert-banner
78+
message="Do you want to prefill Form?"
79+
type="info"
80+
(onSubmit)="preFillForm()"
81+
/>
82+
```
7183

72-
5. Test the application.
84+
7. Test the application.
7385

7486
</Steps>

0 commit comments

Comments
 (0)