Skip to content

Commit

Permalink
refactor: replace @ContentChild annotation usage with contentChild si…
Browse files Browse the repository at this point in the history
…gnal queries (#396)
  • Loading branch information
jrassa authored Jun 25, 2024
1 parent d511345 commit 26cb584
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{ header() ?? (name | titlecase) }}
</ng-template>
<ng-template
[ngTemplateOutlet]="headerTemplate ?? defaultHeaderTemplate"
[ngTemplateOutlet]="headerTemplate() ?? defaultHeaderTemplate"
[ngTemplateOutletContext]="{
header: header()
}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContentChild, Directive, TemplateRef, booleanAttribute, input } from '@angular/core';
import { Directive, TemplateRef, booleanAttribute, contentChild, input } from '@angular/core';

import { AsyAbstractColumnComponent } from './asy-abstract-column.component';
import { HeaderTemplateDirective } from './header-template.directive';
Expand All @@ -8,5 +8,5 @@ export abstract class AsyAbstractValueColumnComponent<T> extends AsyAbstractColu
readonly header = input<string>();
readonly sortable = input(true, { transform: booleanAttribute });

@ContentChild(HeaderTemplateDirective, { read: TemplateRef }) headerTemplate?: TemplateRef<any>;
readonly headerTemplate = contentChild(HeaderTemplateDirective, { read: TemplateRef });
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{ header() ?? (name | titlecase) }}
</ng-template>
<ng-template
[ngTemplateOutlet]="headerTemplate ?? defaultHeaderTemplate"
[ngTemplateOutlet]="headerTemplate() ?? defaultHeaderTemplate"
[ngTemplateOutletContext]="{
header: header()
}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{ header() ?? (name | titlecase) }}
</ng-template>
<ng-template
[ngTemplateOutlet]="headerTemplate ?? defaultHeaderTemplate"
[ngTemplateOutlet]="headerTemplate() ?? defaultHeaderTemplate"
[ngTemplateOutletContext]="{
header: header()
}"
Expand All @@ -26,7 +26,7 @@
{{ listItem }}
</ng-template>
<ng-template
[ngTemplateOutlet]="itemTemplate ?? defaultItemTemplate"
[ngTemplateOutlet]="itemTemplate() ?? defaultItemTemplate"
[ngTemplateOutletContext]="{
listItem: listItem,
item: item,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SelectionModel } from '@angular/cdk/collections';
import { CdkTableModule } from '@angular/cdk/table';
import { CommonModule } from '@angular/common';
import { Component, ContentChild, Directive, OnInit, TemplateRef } from '@angular/core';
import { Component, Directive, OnInit, TemplateRef, contentChild } from '@angular/core';

import { AsyAbstractValueColumnComponent } from '../asy-abstract-value-column.component';

Expand All @@ -23,8 +23,7 @@ export class AsyExpandableListColumnComponent<T>
{
readonly #selectionModel = new SelectionModel<T>();

@ContentChild(ItemTemplateDirective, { read: TemplateRef })
itemTemplate?: TemplateRef<any>;
readonly itemTemplate = contentChild(ItemTemplateDirective, { read: TemplateRef });

toggle(item: T) {
this.#selectionModel.toggle(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{ header() ?? (name | titlecase) }}
</ng-template>
<ng-template
[ngTemplateOutlet]="headerTemplate ?? defaultHeaderTemplate"
[ngTemplateOutlet]="headerTemplate() ?? defaultHeaderTemplate"
[ngTemplateOutletContext]="{
header: header()
}"
Expand Down

0 comments on commit 26cb584

Please sign in to comment.