1

I have integrated ngx-Pagination & it working fine when I test it locally but when I run the command as ng build --prod it shows me error ERROR in ./src/app/myads/myads.component.ngfactory.js error

If anybody knows the solution please answer.

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { FormsModule } from "@angular/forms";

import { AppComponent } from './app.component';
import { NgxPaginationModule } from "ngx-Pagination";


@NgModule({
  declarations: [
    AppComponent,

  ],
  imports: [
    BrowserModule,    
    FormsModule,
    NgxPaginationModule    

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

 }

app.component.ts

import { Component } from '@angular/core';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  collection = ['r', 'k', 'u', 'jj'];
  constructor() { 

  }


}

app.component.html

<ul>
  <li *ngFor="let item of collection | paginate: { itemsPerPage: 2, currentPage: p }">Hello</li>
</ul>  
<pagination-controls (pageChange)="p = $event"></pagination-controls>
12
  • You need to share some code. It is hard to say anything with this little information. Commented Nov 22, 2018 at 15:19
  • So, your referring to the collection in the app component, but declaring and populating the collection in the app module class? Is that working for you? Commented Nov 22, 2018 at 15:52
  • please check now Commented Nov 22, 2018 at 15:52
  • I believe the error arrised because Angular cannot determine the module for class HomeComponent, which could be fixed by adding said component to an NgModule. Just a wild guess. Commented Nov 22, 2018 at 16:00
  • means.........? Commented Nov 22, 2018 at 16:01

2 Answers 2

1

I guess you have a HomeComponent that is not declared in any module?

Try to add HomeComponent in your AppModule declarations

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent
  ],
  imports: [
    BrowserModule,    
    FormsModule,
    NgxPaginationModule    

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

 }
Sign up to request clarification or add additional context in comments.

1 Comment

ERROR in ./src/app/app.component.ngfactory.js Module not found: Error: Can't resolve '../../node_modules/ngx-Pagination/dist/ngx-pagination.ngfactory' in 'D:\paginationdemo\src\app'
1

Try ng build because the compiler doesn't care whether you have declare variables or not but in prod mode this is set to strict.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.