@angular/cdk/scrolling#CdkVirtualForOf TypeScript Examples
The following examples show how to use
@angular/cdk/scrolling#CdkVirtualForOf.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: virtual-for-of.directive.ts From alauda-ui with MIT License | 6 votes |
@Directive({
selector: '[auiVirtualFor][auiVirtualForOf]',
})
export class VirtualForOfDirective<T> extends CdkVirtualForOf<T> {
@Input()
set auiVirtualForOf(
value: DataSource<T> | Observable<T[]> | NgIterable<T> | null | undefined,
) {
this.cdkVirtualForOf = value;
}
@Input()
set auiVirtualForTrackBy(fn: TrackByFunction<T> | undefined) {
this.cdkVirtualForTrackBy = fn;
}
@Input()
set auiVirtualForTemplate(value: TemplateRef<CdkVirtualForOfContext<T>>) {
this.cdkVirtualForTemplate = value;
}
@Input()
set auiVirtualForTemplateCacheSize(size: number) {
this.cdkVirtualForTemplateCacheSize = size;
}
}
Example #2
Source File: for-track-by-id.directive.ts From onchat-web with Apache License 2.0 | 6 votes |
constructor(
@Host() @Optional() private ngForOf: NgForOf<T>,
@Host() @Optional() private cdkForOf: CdkVirtualForOf<T>,
) {
if (this.ngForOf) {
this.ngForOf.ngForTrackBy = (_index: number, item: T) => item.id;
} else if (this.cdkForOf) {
this.cdkForOf.cdkVirtualForTrackBy = (_index: number, item: T) => item.id;
}
}
Example #3
Source File: track-by-property.directive.ts From ng-ant-admin with MIT License | 5 votes |
public constructor(@Host() @Optional() private readonly _ngFor: NgForOf<any>, @Host() @Optional() private readonly _cdkFor: CdkVirtualForOf<any>) {
if(this._ngFor){
this._ngFor.ngForTrackBy = (_: number, item: any) => this._propertyName ? item[this._propertyName] : item;
}
if(this._cdkFor){
this._cdkFor.cdkVirtualForTrackBy = (_: number, item: any) => this._propertyName ? item[this._propertyName] : item;
}
}