Mat-table Sorting Demo not Working

后端 未结 20 2790
旧巷少年郎
旧巷少年郎 2020-12-02 10:55

I am trying to get the mat-table sorting to work locally, and while I can get the data to show up as expected, clicking on the header row does not do the sortin

20条回答
  •  时光说笑
    2020-12-02 11:28

    For anyone that is confused about these namings having to be equal, I did some testing:

    This will work (the name of the property is the same as the column def):

    
         Version 
         {{element.version}} 
    
    
    displayedColumns: string[] = ['version']
    

    This will NOT work (the name of the property is not the same as the column def):

    
         Version 
         {{element.version}} 
    
    
    displayedColumns: string[] = ['version2']
    

    Fyi, this also does NOT work (the length of a property):

    
         Version 
         {{element.ids.length}} 
    
    
    displayedColumns: string[] = ['length']
    

    And neither does this:

    
         Version 
         {{element.ids.length}} 
    
    
    displayedColumns: string[] = ['ids.length']
    

提交回复
热议问题