完整的ng表(排序,搜索)没有workink角度10



我正在尝试使用完整的ng表,但它不适用于angular 10。

当我尝试复制粘贴代码时,在这里出现错误

@Directive({
selector: 'th[mzSortable]',
host: {
'[class.asc]': 'direction === "asc"',
'[class.desc]': 'direction === "desc"',
'(click)': 'rotate()'
}
})

我试着用这个。。。

@Input() sortable: SortColumn = '';
@Input()
direction: SortDirection = '';
@Input()
@HostBinding('class.asc')
get ascClass (): any {
return this.direction === 'asc';
}
@Input()
@HostBinding('class.desc')
get descClass (): any {
return this.direction === 'desc';
}
@Output() sort = new EventEmitter<SortEvent>();
@HostListener('click')
rotate(): void {
this.direction = rotate[this.direction];
this.sort.emit({column: this.sortable, direction: this.direction});
}

现在表格出现了,但我无法对表格进行排序

我找到了,问题是我更改了指令前缀。替换为:

@Directive({
selector: 'th[mzSortable]',
} 
})

通过这个:

@Directive({
selector: 'th[sortable]',
} 
})

最新更新