Skip to content

Instantly share code, notes, and snippets.

@armanozak
Created June 9, 2020 14:32
Show Gist options
  • Save armanozak/7bb72472aab185364b64776e3c32a1d7 to your computer and use it in GitHub Desktop.
Save armanozak/7bb72472aab185364b64776e3c32a1d7 to your computer and use it in GitHub Desktop.
[Attribute Directives to Avoid Repetition in Angular] The Default Properties Directive #blog #angular
@Directive({
// tslint:disable-next-line
selector: 'ngx-datatable[default]',
exportAs: 'ngxDatatableDefault',
})
export class NgxDatatableDefaultDirective {
@Input() class = 'material bordered';
@HostBinding('class')
get classes(): string {
return `ngx-datatable ${this.class}`;
}
constructor(private table: DatatableComponent) {
this.table.columnMode = ColumnMode.force;
this.table.footerHeight = 50;
this.table.headerHeight = 50;
this.table.rowHeight = 'auto';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment