├── src ├── assets │ └── .gitkeep ├── app │ ├── app.component.scss │ ├── components │ │ └── dashboard │ │ │ ├── dashboard.component.css │ │ │ ├── dashboard.component.html │ │ │ ├── dashboard-routing.module.ts │ │ │ ├── dashboard.module.ts │ │ │ ├── dashboard.component.spec.ts │ │ │ └── dashboard.component.ts │ ├── shared │ │ ├── fragments │ │ │ ├── footer │ │ │ │ ├── footer.component.css │ │ │ │ ├── footer.component.html │ │ │ │ ├── footer.component.ts │ │ │ │ └── footer.component.spec.ts │ │ │ ├── main-shell │ │ │ │ ├── main-shell.component.css │ │ │ │ ├── main-shell.component.html │ │ │ │ ├── main-shell.component.ts │ │ │ │ └── main-shell.component.spec.ts │ │ │ └── sidebar │ │ │ │ ├── sidebar.component.spec.ts │ │ │ │ ├── sidebar.component.ts │ │ │ │ ├── sidebar.component.css │ │ │ │ └── sidebar.component.html │ │ ├── components │ │ │ └── mat-custom-table │ │ │ │ ├── components │ │ │ │ └── action-buttons │ │ │ │ │ ├── action-buttons.component.css │ │ │ │ │ ├── action-buttons.component.html │ │ │ │ │ ├── action-buttons.component.spec.ts │ │ │ │ │ └── action-buttons.component.ts │ │ │ │ ├── consts │ │ │ │ └── table.ts │ │ │ │ ├── directives │ │ │ │ ├── table-action.directive.ts │ │ │ │ └── table-action.directive.spec.ts │ │ │ │ ├── mat-custom-table.component.spec.ts │ │ │ │ ├── mat-custom-table.component.css │ │ │ │ ├── mat-custom-table.module.ts │ │ │ │ ├── mat-custom-table.component.html │ │ │ │ └── mat-custom-table.component.ts │ │ ├── models │ │ │ ├── tableButtonAction.ts │ │ │ └── tableColumn.ts │ │ ├── shared.module.ts │ │ └── material.module.ts │ ├── app.component.html │ ├── app.component.ts │ ├── app.module.ts │ ├── app.routing.module.ts │ └── app.component.spec.ts ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── styles.scss ├── main.ts ├── index.html ├── test.ts └── polyfills.ts ├── .editorconfig ├── tsconfig.app.json ├── tsconfig.spec.json ├── .browserslistrc ├── .gitignore ├── README.md ├── package.json ├── tsconfig.json ├── karma.conf.js └── angular.json /src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/components/dashboard/dashboard.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/shared/fragments/footer/footer.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/shared/fragments/main-shell/main-shell.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/shared/fragments/footer/footer.component.html: -------------------------------------------------------------------------------- 1 |

footer works!

2 | -------------------------------------------------------------------------------- /src/app/shared/fragments/main-shell/main-shell.component.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
-------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/components/action-buttons/action-buttons.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decodedscript/angular-material-table-dynamic-columns/HEAD/src/favicon.ico -------------------------------------------------------------------------------- /src/app/shared/models/tableButtonAction.ts: -------------------------------------------------------------------------------- 1 | export interface TableButtonAction { 2 | name: string 3 | value?: any 4 | } 5 | -------------------------------------------------------------------------------- /src/app/shared/models/tableColumn.ts: -------------------------------------------------------------------------------- 1 | export interface TableColumn 2 | { 3 | columnDef:string; 4 | header:string 5 | } -------------------------------------------------------------------------------- /src/app/components/dashboard/dashboard.component.html: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/consts/table.ts: -------------------------------------------------------------------------------- 1 | export const TableConsts = { 2 | actionButton: { 3 | edit: 'edit', 4 | delete: 'delete', 5 | view: 'delete', 6 | }, 7 | } 8 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | 3 | html, body { height: 100%; } 4 | body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } 5 | -------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/directives/table-action.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive } from '@angular/core'; 2 | 3 | @Directive({ 4 | selector: '[appTableAction]' 5 | }) 6 | export class TableActionDirective { 7 | 8 | constructor() { } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'angular-material-table-dynamic-columns'; 10 | } 11 | -------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/directives/table-action.directive.spec.ts: -------------------------------------------------------------------------------- 1 | import { TableActionDirective } from './table-action.directive'; 2 | 3 | describe('TableActionDirective', () => { 4 | it('should create an instance', () => { 5 | const directive = new TableActionDirective(); 6 | expect(directive).toBeTruthy(); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /src/app/shared/fragments/footer/footer.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-footer', 5 | templateUrl: './footer.component.html', 6 | styleUrls: ['./footer.component.css'] 7 | }) 8 | export class FooterComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/app/shared/fragments/main-shell/main-shell.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-main-shell', 5 | templateUrl: './main-shell.component.html', 6 | styleUrls: ['./main-shell.component.css'] 7 | }) 8 | export class MainShellComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/app/components/dashboard/dashboard-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { DashboardComponent } from '@components/dashboard/dashboard.component'; 4 | 5 | 6 | const routes: Routes = [ 7 | { path:'', component:DashboardComponent, pathMatch:'full'} 8 | ]; 9 | 10 | @NgModule({ 11 | imports: [RouterModule.forChild(routes)], 12 | exports: [RouterModule] 13 | }) 14 | export class DashboardRoutingModule { } 15 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AngularMaterialTableDynamicColumns 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/components/action-buttons/action-buttons.component.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 9 | 13 | 17 | -------------------------------------------------------------------------------- /src/app/shared/shared.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FooterComponent } from './fragments/footer/footer.component'; 4 | import { SidebarComponent } from './fragments/sidebar/sidebar.component'; 5 | import { MainShellComponent } from './fragments/main-shell/main-shell.component'; 6 | import { MaterialModule } from './material.module'; 7 | import { RouterModule } from '@angular/router'; 8 | 9 | 10 | @NgModule({ 11 | declarations: [FooterComponent, SidebarComponent, MainShellComponent], 12 | imports: [ 13 | CommonModule, 14 | MaterialModule, 15 | RouterModule 16 | ] 17 | }) 18 | export class SharedModule { } 19 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppComponent } from './app.component'; 5 | import { AppRouteModule } from './app.routing.module'; 6 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 7 | import { FormsModule } from '@angular/forms'; 8 | import { SharedModule } from '@shared/shared.module'; 9 | 10 | @NgModule({ 11 | declarations: [ 12 | AppComponent 13 | ], 14 | imports: [ 15 | BrowserModule, 16 | FormsModule, 17 | AppRouteModule, 18 | SharedModule, 19 | BrowserAnimationsModule 20 | ], 21 | providers: [], 22 | bootstrap: [AppComponent] 23 | }) 24 | export class AppModule { } 25 | -------------------------------------------------------------------------------- /src/app/app.routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core' 2 | import { RouterModule, Routes } from '@angular/router' 3 | import { MainShellComponent } from '@shared/fragments/main-shell/main-shell.component' 4 | 5 | const routes: Routes = [ 6 | { 7 | path: '', 8 | component: MainShellComponent, 9 | children: [ 10 | { 11 | path: '', 12 | loadChildren: () => 13 | import('@components/dashboard/dashboard.module').then( 14 | (m) => m.DashboardModule, 15 | ), 16 | }, 17 | ], 18 | }, 19 | ] 20 | 21 | @NgModule({ 22 | imports: [RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' })], 23 | exports: [RouterModule], 24 | }) 25 | export class AppRouteModule {} 26 | -------------------------------------------------------------------------------- /src/app/components/dashboard/dashboard.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | import { DashboardRoutingModule } from './dashboard-routing.module'; 5 | import { DashboardComponent } from './dashboard.component'; 6 | import { SharedModule } from '@shared/shared.module'; 7 | import { MaterialModule } from '@shared/material.module'; 8 | import { MatCustomTableModule } from '@shared/components/mat-custom-table/mat-custom-table.module'; 9 | 10 | 11 | @NgModule({ 12 | declarations: [DashboardComponent], 13 | imports: [ 14 | CommonModule, 15 | DashboardRoutingModule, 16 | SharedModule, 17 | MaterialModule, 18 | MatCustomTableModule 19 | ] 20 | }) 21 | export class DashboardModule { } 22 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /src/app/shared/fragments/footer/footer.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { FooterComponent } from './footer.component'; 4 | 5 | describe('FooterComponent', () => { 6 | let component: FooterComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ FooterComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(FooterComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/fragments/sidebar/sidebar.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { SidebarComponent } from './sidebar.component'; 4 | 5 | describe('SidebarComponent', () => { 6 | let component: SidebarComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ SidebarComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(SidebarComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/components/dashboard/dashboard.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { DashboardComponent } from './dashboard.component'; 4 | 5 | describe('DashboardComponent', () => { 6 | let component: DashboardComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ DashboardComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(DashboardComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | 16 | # IDEs and editors 17 | /.idea 18 | .project 19 | .classpath 20 | .c9/ 21 | *.launch 22 | .settings/ 23 | *.sublime-workspace 24 | 25 | # IDE - VSCode 26 | .vscode/* 27 | !.vscode/settings.json 28 | !.vscode/tasks.json 29 | !.vscode/launch.json 30 | !.vscode/extensions.json 31 | .history/* 32 | 33 | # misc 34 | /.sass-cache 35 | /connect.lock 36 | /coverage 37 | /libpeerconnection.log 38 | npm-debug.log 39 | yarn-error.log 40 | testem.log 41 | /typings 42 | 43 | # System Files 44 | .DS_Store 45 | Thumbs.db 46 | -------------------------------------------------------------------------------- /src/app/shared/fragments/main-shell/main-shell.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { MainShellComponent } from './main-shell.component'; 4 | 5 | describe('MainShellComponent', () => { 6 | let component: MainShellComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ MainShellComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(MainShellComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/mat-custom-table.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { MatCustomTableComponent } from './mat-custom-table.component'; 4 | 5 | describe('MatCustomTableComponent', () => { 6 | let component: MatCustomTableComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ MatCustomTableComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(MatCustomTableComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/components/action-buttons/action-buttons.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ActionButtonsComponent } from './action-buttons.component'; 4 | 5 | describe('ActionButtonsComponent', () => { 6 | let component: ActionButtonsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ActionButtonsComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ActionButtonsComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/fragments/sidebar/sidebar.component.ts: -------------------------------------------------------------------------------- 1 | import { MediaMatcher } from '@angular/cdk/layout' 2 | import { ChangeDetectorRef, Component, OnInit } from '@angular/core' 3 | 4 | @Component({ 5 | selector: 'app-sidebar', 6 | templateUrl: './sidebar.component.html', 7 | styleUrls: ['./sidebar.component.css'], 8 | }) 9 | export class SidebarComponent implements OnInit { 10 | mobileQuery: MediaQueryList 11 | private _mobileQueryListener: () => void 12 | 13 | constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher) { 14 | this.mobileQuery = media.matchMedia('(max-width: 600px)') 15 | this._mobileQueryListener = () => changeDetectorRef.detectChanges() 16 | this.mobileQuery.addListener(this._mobileQueryListener) 17 | } 18 | 19 | ngOnDestroy(): void { 20 | this.mobileQuery.removeListener(this._mobileQueryListener) 21 | } 22 | ngOnInit() {} 23 | } 24 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting(), 21 | { teardown: { destroyAfterEach: true }}, 22 | ); 23 | 24 | // Then we find all the tests. 25 | const context = require.context('./', true, /\.spec\.ts$/); 26 | // And load the modules. 27 | context.keys().map(context); 28 | -------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/components/action-buttons/action-buttons.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 2 | import { TableButtonAction } from '@shared/models/tableButtonAction' 3 | import { TableConsts } from '@shared/components/mat-custom-table/consts/table' 4 | 5 | @Component({ 6 | selector: '[action-buttons]', 7 | templateUrl: './action-buttons.component.html', 8 | styleUrls: ['./action-buttons.component.css'], 9 | }) 10 | export class ActionButtonsComponent implements OnInit { 11 | constructor() { } 12 | 13 | ngOnInit() { } 14 | 15 | @Input() value: string 16 | @Output() buttonAction: EventEmitter = new EventEmitter() 17 | 18 | onEditClick() { 19 | this.buttonAction.emit({ 20 | name: TableConsts.actionButton.edit, 21 | value: this.value, 22 | }) 23 | } 24 | onDeleteClick() { 25 | this.buttonAction.emit({ name: TableConsts.actionButton.delete }) 26 | } 27 | onViewClick() { 28 | this.buttonAction.emit({ name: TableConsts.actionButton.view }) 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AngularMaterialTableDynamicColumns 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.2.5. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(async () => { 6 | await TestBed.configureTestingModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | }).compileComponents(); 11 | }); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'angular-material-table-dynamic-columns'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.componentInstance; 22 | expect(app.title).toEqual('angular-material-table-dynamic-columns'); 23 | }); 24 | 25 | it('should render title', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.nativeElement as HTMLElement; 29 | expect(compiled.querySelector('.content span')?.textContent).toContain('angular-material-table-dynamic-columns app is running!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /src/app/shared/fragments/sidebar/sidebar.component.css: -------------------------------------------------------------------------------- 1 | .sidebar-container { 2 | display : flex; 3 | flex-direction: column; 4 | position : absolute; 5 | top : 0; 6 | bottom : 0; 7 | left : 0; 8 | right : 0; 9 | } 10 | 11 | .sidebar-is-mobile .sidebar-toolbar { 12 | position: fixed; 13 | /* Make sure the toolbar will stay on top of the content as it scrolls past. */ 14 | z-index : 2; 15 | } 16 | 17 | h1.sidebar-app-name { 18 | margin-left: 8px; 19 | } 20 | 21 | .sidebar-sidenav-container { 22 | /* When the sidenav is not fixed, stretch the sidenav container to fill the available space. This 23 | causes `` to act as our scrolling element for desktop layouts. */ 24 | flex: 1; 25 | background-color: rgb(223, 222, 222)!important; 26 | } 27 | 28 | .sidebar-is-mobile .sidebar-sidenav-container { 29 | /* When the sidenav is fixed, don't constrain the height of the sidenav container. This allows the 30 | `` to be our scrolling element for mobile layouts. */ 31 | flex: 1 0 auto; 32 | 33 | } 34 | 35 | .mat-drawer { 36 | width: 250px; 37 | } 38 | 39 | .router-container { 40 | padding: 5px 20px; 41 | } -------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/mat-custom-table.component.css: -------------------------------------------------------------------------------- 1 | table { 2 | width: 100%; 3 | } 4 | 5 | .table-actionbar { 6 | padding : 2px; 7 | display : flex; 8 | background-color: rgb(235, 238, 238); 9 | } 10 | 11 | .table-actionbar .search-box { 12 | flex: 1; 13 | } 14 | 15 | .search-box mat-form-field { 16 | width: 100%; 17 | 18 | } 19 | 20 | 21 | 22 | .table-actionbar .action-box { 23 | flex : 0 0 50%; 24 | text-align : right; 25 | padding-top: 2px; 26 | 27 | 28 | } 29 | 30 | .table-actionbar .action-box button { 31 | margin-right: 10px; 32 | 33 | } 34 | 35 | ::ng-deep .mat-form-field-wrapper { 36 | padding-bottom: 0; 37 | } 38 | 39 | ::ng-deep .mat-form-field-flex>.mat-form-field-infix { 40 | padding: 0.4em 0px !important; 41 | } 42 | 43 | ::ng-deep .mat-form-field-label-wrapper { 44 | top: -1.5em; 45 | } 46 | 47 | ::ng-deep .mat-form-field-appearance-outline.mat-form-field-can-float.mat-form-field-should-float .mat-form-field-label { 48 | transform: translateY(-1.1em) scale(.75); 49 | width : 133.33333%; 50 | } 51 | 52 | ::ng-deep .action-box button .material-icons { 53 | font-size: 18px; 54 | } 55 | 56 | ::ng-deep .action-box .mat-mini-fab { 57 | height: 34px; 58 | width : 34px; 59 | } -------------------------------------------------------------------------------- /src/app/shared/fragments/sidebar/sidebar.component.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-material-table-dynamic-columns", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/animations": "~12.2.0", 14 | "@angular/cdk": "^12.2.9", 15 | "@angular/common": "~12.2.0", 16 | "@angular/compiler": "~12.2.0", 17 | "@angular/core": "~12.2.0", 18 | "@angular/forms": "~12.2.0", 19 | "@angular/material": "^12.2.9", 20 | "@angular/platform-browser": "~12.2.0", 21 | "@angular/platform-browser-dynamic": "~12.2.0", 22 | "@angular/router": "~12.2.0", 23 | "rxjs": "~6.6.0", 24 | "tslib": "^2.3.0", 25 | "zone.js": "~0.11.4" 26 | }, 27 | "devDependencies": { 28 | "@angular-devkit/build-angular": "~12.2.5", 29 | "@angular/cli": "~12.2.5", 30 | "@angular/compiler-cli": "~12.2.0", 31 | "@types/jasmine": "~3.8.0", 32 | "@types/node": "^12.11.1", 33 | "jasmine-core": "~3.8.0", 34 | "karma": "~6.3.0", 35 | "karma-chrome-launcher": "~3.1.0", 36 | "karma-coverage": "~2.0.3", 37 | "karma-jasmine": "~4.0.0", 38 | "karma-jasmine-html-reporter": "~1.7.0", 39 | "typescript": "~4.3.5" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitReturns": true, 10 | "noFallthroughCasesInSwitch": true, 11 | "sourceMap": true, 12 | "declaration": false, 13 | "downlevelIteration": true, 14 | "experimentalDecorators": true, 15 | "strictPropertyInitialization": false, 16 | "noImplicitAny": false, 17 | "moduleResolution": "node", 18 | "importHelpers": true, 19 | "target": "es2017", 20 | "module": "es2020", 21 | "lib": [ 22 | "es2018", 23 | "dom" 24 | ], 25 | "paths": { 26 | "@assets/*":["src/assets"], 27 | "@components/*":["src/app/components/*"], 28 | "@services/*":["src/app/core/service/*"], 29 | "@models/*":["src/app/core/models/*"], 30 | "@interceptors/*":["src/app/core/interceptors/*"], 31 | "@consts/*":["src/app/core/guards/*"], 32 | "@guards/*":["src/app/core/guards/*"], 33 | "@shared/*":["src/app/shared/*"], 34 | "@material/*":["src/app/material/*"] 35 | } 36 | }, 37 | "angularCompilerOptions": { 38 | "enableI18nLegacyMessageIdFormat": false, 39 | "strictInjectionParameters": true, 40 | "strictInputAccessModifiers": true, 41 | "strictTemplates": true 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/mat-custom-table.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { MatCustomTableComponent } from './mat-custom-table.component'; 4 | import { TableActionDirective } from './directives/table-action.directive'; 5 | import { ActionButtonsComponent } from './components/action-buttons/action-buttons.component'; 6 | import { MatButtonModule } from '@angular/material/button'; 7 | import { CdkTableModule } from '@angular/cdk/table'; 8 | import { MatMenuModule } from '@angular/material/menu'; 9 | import { MatToolbarModule } from '@angular/material/toolbar'; 10 | import { FormsModule } from '@angular/forms'; 11 | import { MatIconModule } from '@angular/material/icon'; 12 | import { MatSortModule } from '@angular/material/sort'; 13 | import { MatInputModule } from '@angular/material/input'; 14 | import { MatCheckboxModule } from '@angular/material/checkbox'; 15 | import { MatPaginatorModule } from '@angular/material/paginator'; 16 | import { MatTableModule } from '@angular/material/table'; 17 | 18 | @NgModule({ 19 | declarations: [MatCustomTableComponent, TableActionDirective, ActionButtonsComponent], 20 | imports: [ 21 | CommonModule, 22 | MatTableModule, 23 | MatButtonModule, 24 | MatIconModule, 25 | CdkTableModule, 26 | MatMenuModule, 27 | MatPaginatorModule, 28 | MatCheckboxModule, 29 | MatToolbarModule, 30 | MatInputModule, 31 | FormsModule, 32 | MatSortModule 33 | ], 34 | exports: [MatCustomTableComponent] 35 | }) 36 | export class MatCustomTableModule { } 37 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/angular-material-table-dynamic-columns'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/mat-custom-table.component.html: -------------------------------------------------------------------------------- 1 |
2 | 12 |
13 | 16 | 19 |
20 | 21 |
22 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | {{ column.header }} 39 | {{ row[column.columnDef] }} 40 | 41 | 42 | 43 | 44 | Action 45 | 46 | {{ element.weight }} 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/app/shared/components/mat-custom-table/mat-custom-table.component.ts: -------------------------------------------------------------------------------- 1 | import { SelectionModel } from '@angular/cdk/collections'; 2 | import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' 3 | import { MatPaginator } from '@angular/material/paginator'; 4 | import { MatSort } from '@angular/material/sort'; 5 | import { MatTableDataSource } from '@angular/material/table'; 6 | 7 | import { TableButtonAction } from '@shared/models/tableButtonAction'; 8 | import { TableColumn } from '@shared/models/tableColumn'; 9 | 10 | @Component({ 11 | selector: 'app-mat-custom-table', 12 | templateUrl: './mat-custom-table.component.html', 13 | styleUrls: ['./mat-custom-table.component.css'], 14 | }) 15 | export class MatCustomTableComponent implements OnInit { 16 | 17 | @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; 18 | @Output() action: EventEmitter = new EventEmitter() 19 | @Input() columns: Array; 20 | @Input() dataset: Array = []; 21 | @ViewChild(MatSort, { static: true }) sort: MatSort; 22 | dataSource: MatTableDataSource; 23 | selection = new SelectionModel(true, []); 24 | displayedColumns: string[] = []; 25 | value: string; 26 | constructor() { } 27 | 28 | 29 | ngOnInit() { 30 | // set checkbox column 31 | this.displayedColumns.push("select"); 32 | 33 | // set table columns 34 | this.displayedColumns = this.displayedColumns.concat(this.columns.map(x => x.columnDef)); // pre-fix static 35 | 36 | // add action column 37 | this.displayedColumns.push("action"); 38 | this.dataSource = new MatTableDataSource(this.dataset); 39 | 40 | // set pagination 41 | this.dataSource.paginator = this.paginator; 42 | } 43 | 44 | onTableAction(e: TableButtonAction): void { 45 | this.action.emit(e) 46 | } 47 | /** Whether the number of selected elements matches the total number of rows. */ 48 | isAllSelected() { 49 | const numSelected = this.selection.selected.length; 50 | const numRows = this.dataSource.data.length; 51 | return numSelected === numRows; 52 | } 53 | 54 | /** Selects all rows if they are not all selected; otherwise clear selection. */ 55 | masterToggle() { 56 | this.isAllSelected() ? 57 | this.selection.clear() : 58 | this.dataSource.data.forEach(row => this.selection.select(row)); 59 | } 60 | ngAfterViewInit() { 61 | this.dataSource.sort = this.sort; 62 | } 63 | applyFilter(event: Event) { 64 | const filterValue = (event.target as HTMLInputElement).value; 65 | this.dataSource.filter = filterValue.trim().toLowerCase(); 66 | } 67 | } 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/app/components/dashboard/dashboard.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core' 2 | 3 | @Component({ 4 | selector: 'app-dashboard', 5 | templateUrl: './dashboard.component.html', 6 | styleUrls: ['./dashboard.component.css'], 7 | }) 8 | export class DashboardComponent implements OnInit { 9 | constructor() { } 10 | columns = [ 11 | 12 | { columnDef: 'name', header: 'Name' }, 13 | { columnDef: 'date', header: 'Date' }, 14 | { columnDef: 'company', header: 'Company' }, 15 | { columnDef: 'country', header: 'Country' }, 16 | { columnDef: 'city', header: 'City' }, 17 | { columnDef: 'phone', header: 'Phone' }, 18 | ] 19 | data: any[]; 20 | ngOnInit() { 21 | // get data from API 22 | this.data = [ 23 | { 24 | "name": "Molly Pope", 25 | "date": "Jul 27, 2021", 26 | "company": "Faucibus Orci Institute", 27 | "country": "New Zealand", 28 | "city": "Campinas", 29 | "phone": "1-403-634-0276" 30 | }, 31 | { 32 | "name": "Alfonso Vinson", 33 | "date": "May 11, 2021", 34 | "company": "Non Ante Corp.", 35 | "country": "United Kingdom", 36 | "city": "Redlands", 37 | "phone": "1-405-411-6336" 38 | }, 39 | { 40 | "name": "Camden David", 41 | "date": "Aug 6, 2022", 42 | "company": "Cursus Et LLP", 43 | "country": "Nigeria", 44 | "city": "Iguala", 45 | "phone": "(415) 628-6853" 46 | }, 47 | { 48 | "name": "Levi Goff", 49 | "date": "Nov 3, 2021", 50 | "company": "Vitae Incorporated", 51 | "country": "Sweden", 52 | "city": "Manavgat", 53 | "phone": "1-545-823-7985" 54 | }, 55 | { 56 | "name": "Madaline Leach", 57 | "date": "Jun 13, 2022", 58 | "company": "Erat Volutpat Corp.", 59 | "country": "Chile", 60 | "city": "Niterói", 61 | "phone": "1-678-156-9674" 62 | }, 63 | { 64 | "name": "Camden David", 65 | "date": "Aug 6, 2022", 66 | "company": "Cursus Et LLP", 67 | "country": "Nigeria", 68 | "city": "Iguala", 69 | "phone": "(415) 628-6853" 70 | }, 71 | { 72 | "name": "Levi Goff", 73 | "date": "Nov 3, 2021", 74 | "company": "Vitae Incorporated", 75 | "country": "Sweden", 76 | "city": "Manavgat", 77 | "phone": "1-545-823-7985" 78 | }, 79 | { 80 | "name": "Madaline Leach", 81 | "date": "Jun 13, 2022", 82 | "company": "Erat Volutpat Corp.", 83 | "country": "Chile", 84 | "city": "Niterói", 85 | "phone": "1-678-156-9674" 86 | } 87 | ]; 88 | } 89 | 90 | onTableAction(event) { 91 | console.log('event', event) 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * IE11 requires the following for NgClass support on SVG elements 23 | */ 24 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 25 | 26 | /** 27 | * Web Animations `@angular/platform-browser/animations` 28 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 29 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 30 | */ 31 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 32 | 33 | /** 34 | * By default, zone.js will patch all possible macroTask and DomEvents 35 | * user can disable parts of macroTask/DomEvents patch by setting following flags 36 | * because those flags need to be set before `zone.js` being loaded, and webpack 37 | * will put import in the top of bundle, so user need to create a separate file 38 | * in this directory (for example: zone-flags.ts), and put the following flags 39 | * into that file, and then add the following code before importing zone.js. 40 | * import './zone-flags'; 41 | * 42 | * The flags allowed in zone-flags.ts are listed here. 43 | * 44 | * The following flags will work for all browsers. 45 | * 46 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 47 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 48 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 49 | * 50 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 51 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 52 | * 53 | * (window as any).__Zone_enable_cross_context_check = true; 54 | * 55 | */ 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by default for Angular itself. 59 | */ 60 | import 'zone.js'; // Included with Angular CLI. 61 | 62 | 63 | /*************************************************************************************************** 64 | * APPLICATION IMPORTS 65 | */ 66 | -------------------------------------------------------------------------------- /src/app/shared/material.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import {A11yModule} from '@angular/cdk/a11y'; 3 | import {DragDropModule} from '@angular/cdk/drag-drop'; 4 | import {PortalModule} from '@angular/cdk/portal'; 5 | import {ScrollingModule} from '@angular/cdk/scrolling'; 6 | import {CdkStepperModule} from '@angular/cdk/stepper'; 7 | import {CdkTableModule} from '@angular/cdk/table'; 8 | import {CdkTreeModule} from '@angular/cdk/tree'; 9 | import {MatAutocompleteModule} from '@angular/material/autocomplete'; 10 | import {MatBadgeModule} from '@angular/material/badge'; 11 | import {MatBottomSheetModule} from '@angular/material/bottom-sheet'; 12 | import {MatButtonModule} from '@angular/material/button'; 13 | import {MatButtonToggleModule} from '@angular/material/button-toggle'; 14 | import {MatCardModule} from '@angular/material/card'; 15 | import {MatCheckboxModule} from '@angular/material/checkbox'; 16 | import {MatChipsModule} from '@angular/material/chips'; 17 | import {MatStepperModule} from '@angular/material/stepper'; 18 | import {MatDatepickerModule} from '@angular/material/datepicker'; 19 | import {MatDialogModule} from '@angular/material/dialog'; 20 | import {MatDividerModule} from '@angular/material/divider'; 21 | import {MatExpansionModule} from '@angular/material/expansion'; 22 | import {MatGridListModule} from '@angular/material/grid-list'; 23 | import {MatIconModule} from '@angular/material/icon'; 24 | import {MatInputModule} from '@angular/material/input'; 25 | import {MatListModule} from '@angular/material/list'; 26 | import {MatMenuModule} from '@angular/material/menu'; 27 | import {MatNativeDateModule, MatRippleModule} from '@angular/material/core'; 28 | import {MatPaginatorModule} from '@angular/material/paginator'; 29 | import {MatProgressBarModule} from '@angular/material/progress-bar'; 30 | import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; 31 | import {MatRadioModule} from '@angular/material/radio'; 32 | import {MatSelectModule} from '@angular/material/select'; 33 | import {MatSidenavModule} from '@angular/material/sidenav'; 34 | import {MatSliderModule} from '@angular/material/slider'; 35 | import {MatSlideToggleModule} from '@angular/material/slide-toggle'; 36 | import {MatSnackBarModule} from '@angular/material/snack-bar'; 37 | import {MatSortModule} from '@angular/material/sort'; 38 | import {MatTableModule} from '@angular/material/table'; 39 | import {MatTabsModule} from '@angular/material/tabs'; 40 | import {MatToolbarModule} from '@angular/material/toolbar'; 41 | import {MatTooltipModule} from '@angular/material/tooltip'; 42 | import {MatTreeModule} from '@angular/material/tree'; 43 | import {OverlayModule} from '@angular/cdk/overlay'; 44 | 45 | @NgModule({ 46 | exports: [ 47 | A11yModule, 48 | CdkStepperModule, 49 | CdkTableModule, 50 | CdkTreeModule, 51 | DragDropModule, 52 | MatAutocompleteModule, 53 | MatBadgeModule, 54 | MatBottomSheetModule, 55 | MatButtonModule, 56 | MatButtonToggleModule, 57 | MatCardModule, 58 | MatCheckboxModule, 59 | MatChipsModule, 60 | MatStepperModule, 61 | MatDatepickerModule, 62 | MatDialogModule, 63 | MatDividerModule, 64 | MatExpansionModule, 65 | MatGridListModule, 66 | MatIconModule, 67 | MatInputModule, 68 | MatListModule, 69 | MatMenuModule, 70 | MatNativeDateModule, 71 | MatPaginatorModule, 72 | MatProgressBarModule, 73 | MatProgressSpinnerModule, 74 | MatRadioModule, 75 | MatRippleModule, 76 | MatSelectModule, 77 | MatSidenavModule, 78 | MatSliderModule, 79 | MatSlideToggleModule, 80 | MatSnackBarModule, 81 | MatSortModule, 82 | MatTableModule, 83 | MatTabsModule, 84 | MatToolbarModule, 85 | MatTooltipModule, 86 | MatTreeModule, 87 | OverlayModule, 88 | PortalModule, 89 | ScrollingModule, 90 | ] 91 | }) 92 | export class MaterialModule { } 93 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "angular-material-table-dynamic-columns": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "style": "scss" 11 | }, 12 | "@schematics/angular:application": { 13 | "strict": true 14 | } 15 | }, 16 | "root": "", 17 | "sourceRoot": "src", 18 | "prefix": "app", 19 | "architect": { 20 | "build": { 21 | "builder": "@angular-devkit/build-angular:browser", 22 | "options": { 23 | "outputPath": "dist/angular-material-table-dynamic-columns", 24 | "index": "src/index.html", 25 | "main": "src/main.ts", 26 | "polyfills": "src/polyfills.ts", 27 | "tsConfig": "tsconfig.app.json", 28 | "inlineStyleLanguage": "scss", 29 | "assets": [ 30 | "src/favicon.ico", 31 | "src/assets" 32 | ], 33 | "styles": [ 34 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 35 | "src/styles.scss" 36 | ], 37 | "scripts": [] 38 | }, 39 | "configurations": { 40 | "production": { 41 | "budgets": [ 42 | { 43 | "type": "initial", 44 | "maximumWarning": "500kb", 45 | "maximumError": "1mb" 46 | }, 47 | { 48 | "type": "anyComponentStyle", 49 | "maximumWarning": "2kb", 50 | "maximumError": "4kb" 51 | } 52 | ], 53 | "fileReplacements": [ 54 | { 55 | "replace": "src/environments/environment.ts", 56 | "with": "src/environments/environment.prod.ts" 57 | } 58 | ], 59 | "outputHashing": "all" 60 | }, 61 | "development": { 62 | "buildOptimizer": false, 63 | "optimization": false, 64 | "vendorChunk": true, 65 | "extractLicenses": false, 66 | "sourceMap": true, 67 | "namedChunks": true 68 | } 69 | }, 70 | "defaultConfiguration": "production" 71 | }, 72 | "serve": { 73 | "builder": "@angular-devkit/build-angular:dev-server", 74 | "configurations": { 75 | "production": { 76 | "browserTarget": "angular-material-table-dynamic-columns:build:production" 77 | }, 78 | "development": { 79 | "browserTarget": "angular-material-table-dynamic-columns:build:development" 80 | } 81 | }, 82 | "defaultConfiguration": "development" 83 | }, 84 | "extract-i18n": { 85 | "builder": "@angular-devkit/build-angular:extract-i18n", 86 | "options": { 87 | "browserTarget": "angular-material-table-dynamic-columns:build" 88 | } 89 | }, 90 | "test": { 91 | "builder": "@angular-devkit/build-angular:karma", 92 | "options": { 93 | "main": "src/test.ts", 94 | "polyfills": "src/polyfills.ts", 95 | "tsConfig": "tsconfig.spec.json", 96 | "karmaConfig": "karma.conf.js", 97 | "inlineStyleLanguage": "scss", 98 | "assets": [ 99 | "src/favicon.ico", 100 | "src/assets" 101 | ], 102 | "styles": [ 103 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 104 | "src/styles.scss" 105 | ], 106 | "scripts": [] 107 | } 108 | } 109 | } 110 | } 111 | }, 112 | "defaultProject": "angular-material-table-dynamic-columns" 113 | } 114 | --------------------------------------------------------------------------------