Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import { Component, Input, IterableDiffer, IterableDiffers, OnInit, DoCheck, IterableChanges } from '@angular/core';
selector: 'data-table',
templateUrl: './data-table.component.html'
export class DataTableComponent implements OnInit, DoCheck {
public data: number[] = [];
public sorted: number[] = [];
private _diff: IterableDiffer<number>;
constructor(private _iterableDiffers: IterableDiffers) { }
public ngOnInit(): void {
this._diff = this._iterableDiffers.find(;
public ngDoCheck(): void {
const changes: IterableChanges<number> = this._diff.diff(;
if (changes) {
private _sort(): void {
this.sorted = number, item2: number) => item1 - item2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.