Reputation: 337
I think this is an easy problem, but I am struggling to understand why this error happens
Unexpected value 'AppModule' imported by the module 'AppModule'. Please add a @NgModule annotation.
I am trying to use ng-sort library [https://www.npmjs.com/package/ng-sort/v/0.1.18] in my angular project to make a table sortable,
this is my app.module.ts
...
import { AppModule as SortModule } from 'ng-sort';
@NgModule({
declarations: [
AppComponent,
LogInComponent,
HomeComponent,
],
imports: [
...
SortModule,
...
],
providers: [ThemeService],
bootstrap: [AppComponent]
})
export class AppModule { }
also, I did it in my clients-mod.module because I use lazy loading
...
import { AppModule as SortModule } from 'ng-sort';
@NgModule({
declarations: [
MainClientComponent,
ClientInfoComponent,
ClientDetailComponent,
ClientsAccComponent,
],
imports: [
...
SortModule
]
})
export class ClientsModModule { }
export class AppModule {
}
any suggestions to resolve this issue or any other way to be able to sort based on the column that is clicked on.
Upvotes: 0
Views: 69
Reputation: 86800
Try it using below method -
import * as SortModule from 'ng-sort';
@NgModule({
declarations: [
AppComponent,
LogInComponent,
HomeComponent,
],
imports: [
...
SortModule.AppModule,
...
],
providers: [ThemeService],
bootstrap: [AppComponent]
})
This is causing issue because appModule is your Main Module's name and you cannot use same name as import.
Upvotes: 1