ng-ytl-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
62 lines (56 loc) • 1.71 kB
text/typescript
import {
Component,
EventEmitter,
Host,
Input,
Optional,
Output,
Renderer2,
ViewEncapsulation,
} from '@angular/core';
import { NzThDirective } from './nz-th.directive';
export class NzTableSortComponent {
_value: string = null;
nzValueChange: EventEmitter<string> = new EventEmitter();
get nzValue(): string {
return this._value;
}
set nzValue(value: string) {
this._value = value;
if (this.nzThDirective) {
if ((this._value !== 'ascend') && (this._value !== 'descend')) {
this._renderer.removeClass(this.nzThDirective._el, 'ant-table-column-sort');
} else {
this._renderer.addClass(this.nzThDirective._el, 'ant-table-column-sort');
}
}
}
_setValue(value: string): void {
if (this.nzValue === value) {
this.nzValue = null;
} else {
this.nzValue = value;
}
this.nzValueChange.emit(this.nzValue);
}
constructor( private nzThDirective: NzThDirective, private _renderer: Renderer2) {
}
}