fredguile / ng2-md-datatable

Angular 5+ DataTable component for using with Material Design 2
https://www.npmjs.com/package/ng2-md-datatable
MIT License
38 stars 13 forks source link

Components not available for lazy loaded modules #37

Closed dynamics12 closed 7 years ago

dynamics12 commented 7 years ago

I have included the MdDataTableModule in the AppModule but the components are not available when used in a lazy-loaded module. I used to import this module in SharedModule but latest release doesn't allow me to do that anymore.

Error: Template parse errors: 'ng2-md-datatable-column' is not a known element:

  1. If 'ng2-md-datatable-column' is an Angular component, then verify that it is part of this module.
  2. If 'ng2-md-datatable-column' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
fredguile commented 7 years ago

Hi! Totally right, I'm sorry I still haven't approached lazy loading of routes. Any idea on how to solve it?

michalmw commented 7 years ago

Is very good guestion. i Rly need this too

fredguile commented 7 years ago

Hey guys, very sorry I still couldn't find time to dig into this problem (had anybody a look at this?).

Just a suggestion in the meantime, lazy loaders, could you try applying to you Angular-CLI app the config change that @clydin suggests in this issue?

https://github.com/angular/angular-cli/issues/6505

(let me know if it works...)

leocaseiro commented 7 years ago

You might want to import MdDataTableModule on your LazyLoduled module.

gmerabishvili commented 7 years ago

Could anyone provide a documentation of the table? I want to add some icons next to checkboxes. Any help?

fredguile commented 7 years ago

This probably deserves another issue/feature request. Right now you can't override the checkboxes part, there's just a selectable attribute on the datatable to show/hide them.

@leocaseiro did the MdDataTableModule worked for you from a LazyModule? Never had chance to try that so far...

Eswan commented 7 years ago

Same bug for me

fredguile commented 7 years ago

Okay at last I had time to play with lazy routes. There's no bug related to lazy loading.

I've been playing with 2 lazy routes, alongside with non-lazy routes. All my MdDatatable components are in the lazy routes. Some of them are preloaded, some not.

To give you an insight of my code:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';

...

import { MdDataTableModule } from 'ng2-md-datatable';

@NgModule({
  imports: [
    // don't forget that
    CommonModule,

    // Material 2 modules, pick the ones you use

    // ng2-md-datatable
    MdDataTableModule,

    RouterModule.forChild(Routes),
    ],
  declarations: [...],
  exports: [RouterModule],
})
export class BlablaLazyRoutingModule { }

From the main Routes config:

{
    path: '',
    loadChildren: 'app/routing/blabla.routing.module#BlablaLazyRoutingModule',
},

I'll close this one until one prove there's a bug with ng2-md-datatable.

My current setup: