Skip to content

Commit

Permalink
refactor: migrate example inputs to signal inputs
Browse files Browse the repository at this point in the history
This commit was generated using the signal input migration.
  • Loading branch information
devversion committed Sep 25, 2024
1 parent 6beab1c commit 846299c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@if (shouldRun) {
@if (shouldRun()) {
<div class="example-header">Content before</div>
<cdk-virtual-scroll-viewport scrollWindow itemSize="50">
<div *cdkVirtualFor="let item of items" class="example-item">{{item}}</div>
</cdk-virtual-scroll-viewport>
<div class="example-footer">Content after</div>
}

@if (!shouldRun) {
@if (!shouldRun()) {
<div>Please open on StackBlitz to see result</div>
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {ChangeDetectionStrategy, Component, input} from '@angular/core';
import {ScrollingModule} from '@angular/cdk/scrolling';

/** @title Virtual scrolling window */
Expand All @@ -11,7 +11,7 @@ import {ScrollingModule} from '@angular/cdk/scrolling';
imports: [ScrollingModule],
})
export class CdkVirtualScrollWindowScrollingExample {
@Input() shouldRun = /(^|.)(stackblitz|webcontainer).(io|com)$/.test(window.location.host);
readonly shouldRun = input(/(^|.)(stackblitz|webcontainer).(io|com)$/.test(window.location.host));

items = Array.from({length: 100000}).map((_, i) => `Item #${i}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
AfterContentInit,
Component,
ContentChildren,
Input,
AfterViewInit,
QueryList,
ViewChild,
ContentChild,
forwardRef,
input,
} from '@angular/core';
import {MatSort, MatSortModule} from '@angular/material/sort';
import {
Expand Down Expand Up @@ -94,9 +94,8 @@ export class WrapperTable<T> implements AfterContentInit {

@ViewChild(MatTable, {static: true}) table: MatTable<T>;

@Input() columns: string[];

@Input() dataSource: DataSource<T>;
readonly columns = input.required<string[]>();
readonly dataSource = input.required<DataSource<T>>();

ngAfterContentInit() {
this.columnDefs.forEach(columnDef => this.table.addColumnDef(columnDef));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<table mat-table [dataSource]="dataSource()" class="mat-elevation-z8">
<ng-content></ng-content>

<!-- Position Column -->
Expand Down

0 comments on commit 846299c

Please sign in to comment.