import { Component } from '@angular/core'; @Component({ selector: 'dynamic-height-demo', template: `

Dynamic Height w/ Virtual Scrolling Source

` }) export class DynamicHeightComponent { rows = []; expanded = {}; timeout: any; constructor() { this.fetch((data) => { this.rows = data; }); } fetch(cb) { const req = new XMLHttpRequest(); req.open('GET', `assets/data/100k.json`); req.onload = () => { const rows = JSON.parse(req.response).splice(0, 100); for(const row of rows) { row.height = Math.floor(Math.random() * 80) + 50; } cb(rows); }; req.send(); } getRowHeight(row) { if(!row) return 50; if(row.height === undefined) return 50; return row.height; } }