Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何在可重复使用的表格中使用matSort?_Angular_Typescript_Angular Material - Fatal编程技术网

Angular 如何在可重复使用的表格中使用matSort?

Angular 如何在可重复使用的表格中使用matSort?,angular,typescript,angular-material,Angular,Typescript,Angular Material,我正在尝试使用Mat Sort将排序后的数据传递给我的可重用表组件 这是我在parent.component.html中使用的代码行: <app-table matSort [colData]="{'headers':headerData}" [rowData]="rowData" (matSortChange)="sortData($event)" ></app-table> 但它什么都不

我正在尝试使用Mat Sort将排序后的数据传递给我的可重用表组件 这是我在parent.component.html中使用的代码行:

<app-table matSort  
  [colData]="{'headers':headerData}" 
  [rowData]="rowData" 
  (matSortChange)="sortData($event)"
></app-table>
但它什么都不排序。
我怎样才能赶上这次活动?感谢您的回复。

您将事件输出为notify。所以你会像这样使用它:

(notify)="sortData($event)"

在您的表组件html中。“matSortChange”是由matSort发出的,您已经在onClick中使用过它。

我也尝试过这个方法,但仍然不起作用,我尝试过在onClick(事件)方法中放置一个console.log(事件),但似乎没有调用它。调用matSort时,它是错误的,并且输出是来自material Sort的{active:“Id”,direction:“desc”},也许我需要改变它好吧,多亏了你的建议,我终于修好了,谢谢!
@Output() notify: EventEmitter<any>=new EventEmitter<any>();
 onClick(event) {
    this.notify.emit(event);
  }
(notify)="sortData($event)"