valor-software / ng2-table

Simple table extension with sorting, filtering, paging... for Angular2 apps
http://valor-software.github.io/ng2-table/
MIT License
553 stars 336 forks source link

Uncaught Error: Unexpected module 'Ng2TableModule' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation. #575

Open Harelebel opened 7 years ago

Harelebel commented 7 years ago

Hello, getting the above error while trying to add the ng2-table to new angular 2 application. here is my app.module: `import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; import { Ng2TableModule, NgTableComponent } from 'ng2-table/ng2-table';

import { AppComponent } from './app.component'; import {DataService} from './data.service';

@NgModule({ declarations: [ Ng2TableModule, NgTableComponent, AppComponent ], imports: [ BrowserModule, FormsModule, HttpModule

], providers: [DataService], bootstrap: [AppComponent] }) export class AppModule { } `

Thanks in advance

erichdiniz commented 5 years ago

Hey man, you've probably solved this by now, but the wrong thing that you have there is that Ng2TableModule, should've been on the imports not on declarations.

Aspheria commented 5 years ago

I did the same mistake.

now, its right

import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpClientModule } from '@angular/common/http'; import { NbPasswordAuthStrategy, NbAuthModule, } from '@nebular/auth'; import { Ng2SmartTableModule } from 'ng2-smart-table';

import { NbAlertModule, NbCheckboxModule, NbInputModule, NbThemeModule, NbLayoutModule, NbSidebarModule, NbMenuModule, NbIconModule, NbCardModule, NbSelectModule, NbActionsModule, NbButtonModule, NbSearchModule, NbUserModule, NbContextMenuModule, NbStepperModule, NbListModule, NbRadioModule,

} from '@nebular/theme'; import { LayoutService } from './@core/utils';

import { NbEvaIconsModule } from '@nebular/eva-icons'; import { NgxPaginationModule } from 'ngx-pagination';

import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module';

import { LoginComponent } from './pages/login/login.component'; import { DashboardComponent } from './pages/dashboard/dashboard.component'; import { IsTrueOrFalseNumberPipe } from './shared/pipes/True-or-False/TrueOrFalse-number/is-true-or-false-number.pipe'; import { IsTrueOrFalsePipe } from './shared/pipes/True-or-False/TrueOrFalse-boolean/is-true-or-false.pipe'; import { OperationIdToNamePipe } from './shared/pipes/ID-To-name/Operations/operation-id-to-name.pipe'; import { ProductIdToNamePipe } from './shared/pipes/ID-To-name/Products/product-id-to-name.pipe'; import { CompaniesFormComponent } from './shared/static-components/forms/companies-form/companies-form.component'; import { HeaderComponent } from './shared/static-components/header/header.component'; import { MenuComponent } from './shared/static-components/menu/menu.component'; import { WizardCredentialComponent } from './pages/Wizard-Credentials/wizard-credential.component'; import { SourceFormComponent } from './shared/static-components/forms/source-form/source-form.component'; import { ProductFormComponent } from './shared/static-components/forms/product-form/product-form.component'; import { CredentialFormComponent } from './shared/static-components/forms/credential-form/credential-form.component'; import { CompanylogininformationListComponent } from './pages/companylogininformation-list/companylogininformation-list.component';

const components = [ AppComponent, HeaderComponent, MenuComponent, DashboardComponent, LoginComponent, ];

const modules = [ BrowserModule, AppRoutingModule, BrowserAnimationsModule, NbThemeModule.forRoot({ name: 'default' }), NbLayoutModule, NbEvaIconsModule, NbSidebarModule.forRoot(), NbMenuModule.forRoot(), NbIconModule, NbCardModule, NbSelectModule, NbSearchModule, NbContextMenuModule, NbButtonModule, NbCheckboxModule, NbInputModule, NbAlertModule, NbActionsModule, NbListModule, HttpClientModule, ReactiveFormsModule, FormsModule, NbRadioModule, NbUserModule, BrowserModule, NbStepperModule, Ng2SmartTableModule, NgxPaginationModule, NbAuthModule.forRoot({ strategies: [ NbPasswordAuthStrategy.setup({ name: 'login',

    login: {
      redirect: {
        success: 'dashboard',
        failure: 'dashboard',
      },
    }}),
    ],
forms: {
  validation: {
    password: {
      required: true,
      minLength: 4,
      maxLength: 25,
    },
    login: {
      required: true,
      minLength: 2,
    },
    filter: {
      required: true,
    }
  }
 }

}), ];

@NgModule({ declarations: [ components, IsTrueOrFalseNumberPipe, IsTrueOrFalsePipe, OperationIdToNamePipe, ProductIdToNamePipe, WizardCredentialComponent, CompaniesFormComponent, SourceFormComponent, ProductFormComponent, CredentialFormComponent, CompanylogininformationListComponent,

], imports: [modules], providers: [LayoutService], bootstrap: [AppComponent],

})

export class AppModule {

}