When enabling sorting on first load value get undefine and give exception in angular

  Kiến thức lập trình
core.mjs:7739 ERROR Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'undefined'. Current value: ''.. Find more at https://angular.io/errors/NG0100
at throwErrorIfNoChangesMode (core.mjs:7940:1)
at bindingUpdated (core.mjs:12832:1)
at ɵɵproperty (core.mjs:14565:1)
at SomeComponent (bydate.component.html:85:73)
at executeTemplate (core.mjs:9717:1)
at refreshView (core.mjs:9580:1)
at refreshComponent (core.mjs:10777:1)
at refreshChildComponents (core.mjs:9376:1)
at refreshView (core.mjs:9630:1)
at refreshEmbeddedViews (core.mjs:10731:1)

this is the error

 generateReport(event?: LazyLoadEvent){
    debugger;
    if (event && this.primengTableHelper.shouldResetPaging(event)) {
        this.paginator.changePage(0);
        return;
    }

//Issue is here
this.input.sorting = this.dataTable != undefined ? this.primengTableHelper.getSorting(this.dataTable):’caseDescription desc’;
//this.input.sorting = this.primengTableHelper.getSorting(this.dataTable);
// if(this.input.sorting == ”) this.input.sorting = ‘caseDescription desc’;
this.input.paymentTypeId = this.input.isPostedByDateOfService ? this.input.paymentTypeId : “”;
this.input.skipCount = this.primengTableHelper.getSkipCount(this.paginator, event);
this.input.maxResultCount = this.primengTableHelper.getMaxResultCount(this.paginator, event);
this.showMainSpinner();

LEAVE A COMMENT