Я надеюсь, что у вашего компонента OnPush
ChangeDetectionStrategy, как показано ниже
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
Переместите this.changeDetectorRefs.detectChanges();
после установки источника данных, чтобы решить вашу проблему.
ngOnInit() {
this.getCustomers();
}
getCustomers(): void {
this.purchaseService.getCustomersInfo()
.subscribe(customers => {
this.options = customers;
this.dataSource=customers;
this.changeDetectorRefs.detectChanges();
});
}
displayedColumns = ['id', 'name','purchases','actions'];
Рабочий образец