Skip to content

Commit d129d20

Browse files
MeAkibkirjs
authored andcommitted
docs: standardize component decorator placeholders in markdown
Updates `@Component({ ... })` to `@Component({/*...*/})` across documentation examples for consistency and clearer formatting.
1 parent 8c8c5b2 commit d129d20

16 files changed

Lines changed: 75 additions & 43 deletions

File tree

adev/src/content/best-practices/style-guide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ ensures that the value set by Angular is not overwritten.
197197

198198
```ts
199199
@Component({
200-
/* ... */
200+
/*...*/
201201
})
202202
export class UserProfile {
203203
readonly userId = input();
@@ -211,7 +211,7 @@ advice applies to output properties and queries, but not input properties.
211211

212212
```ts
213213
@Component({
214-
/* ... */
214+
/*...*/
215215
})
216216
export class UserProfile {
217217
@Output() readonly userSaved = new EventEmitter<void>();
@@ -276,7 +276,7 @@ then delegate to more specific behaviors based on the event details:
276276

277277
```ts
278278
@Component({
279-
/* ... */
279+
/*...*/
280280
})
281281
class RichText {
282282
handleKeydown(event: KeyboardEvent) {
@@ -323,7 +323,7 @@ your class, import and `implement` these interfaces to ensure that the methods a
323323
import {Component, OnInit} from '@angular/core';
324324

325325
@Component({
326-
/* ... */
326+
/*...*/
327327
})
328328
export class UserProfile implements OnInit {
329329
// The `OnInit` interface ensures this method is named correctly.

adev/src/content/guide/components/anatomy-of-components.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ You show a component by creating a matching HTML element in the template of _oth
9797
export class ProfilePhoto { }
9898
9999
@Component({
100-
imports: [ProfilePhoto],
101-
template: `<profile-photo />`
100+
imports: [ProfilePhoto],
101+
template: `<profile-photo />`
102102
})
103103
export class UserProfile { }
104104
```

adev/src/content/guide/components/dom-apis.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ directly interact with a component's DOM. Components can inject ElementRef to ge
77
component's host element:
88

99
```ts
10-
@Component({...})
10+
@Component({
11+
/*...*/
12+
})
1113
export class ProfilePhoto {
1214
constructor() {
1315
const elementRef = inject(ElementRef);
@@ -23,7 +25,9 @@ You can use Angular's `afterEveryRender` and `afterNextRender` functions to regi
2325
callback** that runs when Angular has finished rendering the page.
2426

2527
```ts
26-
@Component({...})
28+
@Component({
29+
/*...*/
30+
})
2731
export class ProfilePhoto {
2832
constructor() {
2933
const elementRef = inject(ElementRef);

adev/src/content/guide/components/inheritance.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export class ListboxBase {
1212
value: string;
1313
}
1414

15-
@Component({ ... })
15+
@Component({
16+
/*...*/
17+
})
1618
export class CustomListbox extends ListboxBase {
1719
// CustomListbox inherits the `value` property.
1820
}
@@ -70,12 +72,16 @@ and their own.
7072
If a base class injects dependencies as constructor parameters, the child class must explicitly class these dependencies to `super`.
7173

7274
```ts
73-
@Component({ ... })
75+
@Component({
76+
/*...*/
77+
})
7478
export class ListboxBase {
75-
constructor(private element: ElementRef) { }
79+
constructor(private element: ElementRef) {}
7680
}
7781

78-
@Component({ ... })
82+
@Component({
83+
/*...*/
84+
})
7985
export class CustomListbox extends ListboxBase {
8086
constructor(element: ElementRef) {
8187
super(element);
@@ -90,15 +96,19 @@ implements `ngOnInit` _overrides_ the base class's implementation. If you want t
9096
class's lifecycle method, explicitly call the method with `super`:
9197

9298
```ts
93-
@Component({ ... })
99+
@Component({
100+
/*...*/
101+
})
94102
export class ListboxBase {
95103
protected isInitialized = false;
96104
ngOnInit() {
97105
this.isInitialized = true;
98106
}
99107
}
100108

101-
@Component({ ... })
109+
@Component({
110+
/*...*/
111+
})
102112
export class CustomListbox extends ListboxBase {
103113
override ngOnInit() {
104114
super.ngOnInit();

adev/src/content/guide/components/inputs.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ TIP: While the Angular team recommends using the signal-based `input` function f
294294
You can alternatively declare component inputs by adding the `@Input` decorator to a property:
295295

296296
```ts {highlight:[3]}
297-
@Component({...})
297+
@Component({
298+
/*...*/
299+
})
298300
export class CustomSlider {
299301
@Input() value = 0;
300302
}
@@ -315,7 +317,9 @@ The `@Input` decorator accepts a config object that lets you change the way that
315317
You can specify the `required` option to enforce that a given input must always have a value.
316318

317319
```ts {highlight:[3]}
318-
@Component({...})
320+
@Component({
321+
/*...*/
322+
})
319323
export class CustomSlider {
320324
@Input({required: true}) value = 0;
321325
}
@@ -346,7 +350,9 @@ function trimString(value: string | undefined) {
346350
You can specify the `alias` option to change the name of an input in templates.
347351

348352
```ts {highlight:[3]}
349-
@Component({...})
353+
@Component({
354+
/*...*/
355+
})
350356
export class CustomSlider {
351357
@Input({alias: 'sliderValue'}) value = 0;
352358
}

adev/src/content/guide/components/lifecycle.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ next phase.
256256
```ts
257257
import {Component, ElementRef, afterNextRender} from '@angular/core';
258258

259-
@Component({...})
259+
@Component({
260+
/*...*/
261+
})
260262
export class UserProfile {
261263
private prevPadding = 0;
262264
private elementHeight = 0;
@@ -281,7 +283,7 @@ export class UserProfile {
281283
if (didWrite) {
282284
this.elementHeight = nativeElement.getBoundingClientRect().height;
283285
}
284-
}
286+
},
285287
});
286288
}
287289
}

adev/src/content/guide/components/programmatic-rendering.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ chunks automatically and loaded only when necessary, based on the configured tri
2020
template.
2121

2222
```angular-ts
23-
@Component({ ... })
23+
@Component({/*...*/})
2424
export class AdminBio { /* ... */ }
2525
26-
@Component({ ... })
26+
@Component({/*...*/})
2727
export class StandardBio { /* ... */ }
2828
2929
@Component({

adev/src/content/guide/components/queries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ In some cases, especially with `viewChild`, you know with certainty that a speci
150150

151151
```ts
152152
@Component({
153-
/* ... */
153+
/*...*/
154154
})
155155
export class CustomCard {
156156
header = viewChild.required(CustomCardHeader);

adev/src/content/guide/di/overview.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ export class Navbar {
9696
You can inject dependencies during construction of a component, directive, or service. The call to [`inject`](/api/core/inject) can appear in either the `constructor` or in a field initializer. Here are some common examples:
9797

9898
```ts
99-
@Component({...})
99+
@Component({
100+
/*...*/
101+
})
100102
export class MyComponent {
101103
// ✅ In class field initializer
102104
private service = inject(MyService);

adev/src/content/guide/forms/reactive-forms.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ import {
451451
} from '@angular/forms';
452452

453453
@Component({
454-
/* ... */
454+
/*...*/
455455
})
456456
export class UnifiedEventsBasicComponent {
457457
form = new FormGroup({
@@ -601,7 +601,9 @@ When updating form controls programmatically, you have precise control over how
601601
By default `emitEvent: true`, any change to a control emits events through the `valueChanges` and `statusChanges` observables. Setting `emitEvent: false` suppresses these emissions, which is useful when setting values programmatically without triggering reactive behavior like auto-save, avoiding circular updates between controls, or performing bulk updates where events should emit only once at the end.
602602

603603
```ts
604-
@Component({/* ... */})
604+
@Component({
605+
/* ... */
606+
})
605607
export class BlogPostEditor {
606608
postForm = new FormGroup({
607609
title: new FormControl(''),
@@ -610,16 +612,15 @@ export class BlogPostEditor {
610612

611613
constructor() {
612614
// Auto-save draft every time user types
613-
this.postForm.valueChanges.subscribe(formValue => {
615+
this.postForm.valueChanges.subscribe((formValue) => {
614616
this.autosaveDraft(formValue);
615617
});
616618
}
617619

618620
loadExistingDraft(savedDraft: {title: string; content: string}) {
619621
// Restore draft without triggering auto-save
620-
this.postForm.setValue(savedDraft, { emitEvent: false });
622+
this.postForm.setValue(savedDraft, {emitEvent: false});
621623
}
622-
623624
}
624625
```
625626

0 commit comments

Comments
 (0)