"ERROR in Ng2PaginationModule is not an NgModule" after compiling succesfully
See original GitHub issueAngular 2 version: 2.3.1
ng2-pagination version: 2.0.0
Description of issue:
After importing the Ng2PaginationModule in my app.module.ts, everything works, but after building (angular-cli@latest) it outputs an error: ERROR in Ng2PaginationModule is not an NgModule
Steps to reproduce: Simply install using NPM and use in your application.
import { Ng2PaginationModule } from 'ng2-pagination';
...
@NgModule({
imports: [
BrowserModule,
Ng2PaginationModule,
FormsModule,
HttpModule
],
...
Expected result: Everything should compile without errors. Actually, it compiles and outputs all bundle files, but after it’s done it still throws an error, messing with my teamcity build.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:19 (9 by maintainers)
Top Results From Across the Web
Appears in the NgModule.imports of AppModule, but could not ...
After updating my app from Angular 9 -> 10 -> 11, I received the NG6002 error for package "ngx-lightbox" when attempting ng build...
Read more >NgModule FAQ - Angular
An NgModule can even export a module that it doesn't import. What should I not export?link. Don't export the following: Private components, directives,...
Read more >Angular Modules and NgModule - Complete Guide
If we try to use a component directly that is not part of a module, we will get the following error: Unhandled Promise...
Read more >Quick Angular fix: the NgModule 'AppModule' needs to be ...
When working on a Angular project I got the following error when working with multiple modules: The NgModule 'AppModule' needs to be compiled...
Read more >Server-side pagination in Angular with ngx-pagination
Once the installation is done successfully, open the project ... import {NgxPaginationModule} from 'ngx-pagination'; @NgModule({ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

<pagination-controls (pageChange)=“p = $event”></pagination-controls>
export class XComponent { … p: number;
just add p in your typescript, add should be work. (test it on my app with ng cli 1.0.0à ng build --prod
@NYearOldCoder The reason is that
ng builddoes not do the step of compiling your templates into TypeScript, which does happen then you use the--prodflag. Once a template is compiled into a TypeScript class, it becomes apparent that the variable “p” does not exist on the component, leading to the error.In dev mode (
ng build) this compilation step happens dynamically at run-time, and therefore the TypeScript compiler does not get a chance to complain about it.