ngx-pagination: Problem when working with AOT

Hi, thanks for contributing!

This project is maintained in my spare time, so in order to help me address your issue as quickly as possible, please provide as much of the following information as you can.

– Michael

Angular 2 version: rc.7 ng2-pagination version: latest Description of issue: Error when using AOT compiler Steps to reproduce: see above Expected result:

Actual result: Error: Unexpected value ‘Ng2PaginationModule’ imported by the module ‘SparepartM odule’ Demo: (if possible, edit this Plunker demo and paste the link to your fork)

Any relevant code:


import { Ng2PaginationModule } from 'ng2-pagination';
  imports: [
    SharedModule,
    PalipediaDocumentModule,
    Ng2PaginationModule,

ngc -p src

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 22 (9 by maintainers)

Most upvoted comments

Created pull request #80 to resolve this. Tested with my AOT setup and the resulting build works.

@HristoKolev thanks for the detailed description there. I’ll get around to this next week probably.

I was having the same problem, but I was able to solve it by updating the commonJS plugin in my rollup config to have the following namedExport: ‘node_modules/ng2-pagination/index.js’: [‘Ng2PaginationModule’]

That fixed the issue for me.

@noemi-salaun you are totally correct, I forgot to add that. Will fix and issue new release.

When compiling with AOT, I get import errors for the PaginationControlsDirective.

Error at /home/noemi/myproject/aot/app/my.component.ngfactory.ts:39:27: Cannot find module '../node_modules/ng2-pagination/dist/pagination-controls.directive.ngfactory'.

When I re-run ngc a second time, it works.

I think maybe it’s because you do not export PaginationControlsDirective.

In src/ng2-pagination.ts

import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {PaginatePipe} from './paginate.pipe';
import {PaginationService} from './pagination.service';
import {PaginationControlsComponent} from './pagination-controls.component';
import {PaginationControlsDirective} from './pagination-controls.directive';

export {PaginationInstance} from './pagination-instance';
export {PaginationService} from './pagination.service';
export {PaginationControlsComponent} from './pagination-controls.component';
export {PaginationControlsDirective} from './pagination-controls.directive'; // <-- ADD THIS
export {PaginatePipe} from './paginate.pipe';