user10469417
user10469417

Reputation:

Why Angular 6 app throwing error while deploying for production?

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>

Upvotes: 1

Views: 372

Answers (2)

Vinay Partap Singh
Vinay Partap Singh

Reputation: 11

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.

Upvotes: 1

TooLiPHoNe.NeT
TooLiPHoNe.NeT

Reputation: 499

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 {     

 }

Upvotes: 1

Related Questions