【发布时间】:2019-06-20 20:29:58
【问题描述】:
我已经集成了 ngx-Pagination,当我在本地测试它时它工作正常,但是当我以 ng build --prod 运行命令时,它显示错误 ERROR in ./src/ app/myads/myads.component.ngfactory.js
如果有人知道解决方案,请回答。
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>
【问题讨论】:
-
你需要分享一些代码。用这么少的信息很难说什么。
-
那么,您指的是应用程序组件中的
collection,而是在应用程序模块类中声明和填充collection?这对你有用吗? -
请立即查看
-
我相信这个错误是因为 Angular 无法确定 HomeComponent 类的模块,这可以通过将所述组件添加到 NgModule 来解决。只是一个疯狂的猜测。
-
意思是......?