-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.stack.imgur.com/DVTBB.jpg

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

Mattias
  • 11
  • 4

1 Answers1

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.

uminder
  • 23,831
  • 5
  • 37
  • 72
  • Still doesn't work, i get many error and in inspection module in browser I get message that .slice is not an typescript function. – Mattias Apr 01 '19 at 07:50