-2

I'm trying to implement sort function to my table in angular, and all my data from my rest api does show up in the table. But the problem I get is when I click on arrow my data in table doesn't sort. My data comes from a method in other ts file witch get the data from rest api

What I have tried is followed this links but it doesn't work

Angular Material Table Sorting - Data Doesn't sort when inside a *ngIf condition

Sorting Not Working Angular Material Design Table

https://material.angular.io/components/table/overview#sorting

I have some problem to upload code

This is my controller code, the method to get code from rest api: https://imgur.com/a/qX2AcNJ

This is my code who should take a data from controller and show in html: https://i.sstatic.net/DVTBB.jpg

This is the html file: https://imgur.com/a/q4FJmuK

1 Answer 1

0

Your table is missing the instruction on how sorting must be done. You should add the following to your table element.

<table ... (matSortChange)="sortData($event)">

Then you need to to add the sortData method to your ListComponent. A detailed example can be found at https://material.angular.io/components/sort/examples.

Sign up to request clarification or add additional context in comments.

1 Comment

Still doesn't work, i get many error and in inspection module in browser I get message that .slice is not an typescript function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.