2017-10-23 17 views
0

ページ設定ロジックを別のモジュールに配置し、AppModuleにインポートしました。以下は私のページネーションモジュールのコードとAppModuleです。角度:ng build --prod "クラスのモジュールを特定できません。NgModuleにクラスを追加して修正してください。"

PagingUtilitiesModule:

import { NgModule, ModuleWithProviders, Injector } from '@angular/core'; 
import { CommonModule } from '@angular/common'; 
import { OrderByPipe } from './order-by.pipe'; 
import { FilterPipe } from './filter.pipe'; 
import { SortByDirective } from './sort-by.directive'; 
import { PaginationComponent } from './pagination/pagination.component'; 
import { ServiceLocator } from './service-locator'; 

@NgModule({ 
    imports: [ 
    CommonModule 
    ], 
    declarations: [ 
    SortByDirective, 
    PaginationComponent 
    ], 
    exports: [ 
    SortByDirective, 
    PaginationComponent 
    ] 
}) 
export class PagingUtilitiesModule { 
    constructor(private injector: Injector) { 
    ServiceLocator.injector = this.injector; 
    } 

    static forRoot(): ModuleWithProviders { 
    return { 
     ngModule: PagingUtilitiesModule, 
     providers: [ 
     FilterPipe, 
     OrderByPipe 
     ] 
    } 
    } 
} 

AppModule:

import { NgModule } from '@angular/core'; 
import { Location } from '@angular/common'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { ReactiveFormsModule, FormsModule } from '@angular/forms'; 
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; 

import { MultiselectDropdownModule } from 'angular-2-dropdown-multiselect'; 
import { FileUploadModule } from 'ng2-file-upload'; 
import { SlimLoadingBarModule } from 'ng2-slim-loading-bar'; 

import { AppRoutingModule } from './app-routing/app-routing.module'; 
import { PagingUtilitiesModule } from './shared/paging-utilities/paging-utilities.module'; 

import { AppComponent } from './app.component'; 
import { HomeComponent } from './home/home.component'; 
import { LoginComponent } from './login/login.component'; 
import { AgreementComponent } from './agreement/agreement.component'; 
import { DatepickerDirective } from './shared/datepicker.directive'; 
import { HeaderComponent } from './header/header.component'; 
import { CreatePriceListComponent } from './create-price-list/create-price-list.component'; 
import { ExcelReaderService } from './shared/excel-reader.service'; 

import { AgreementDetailsService } from './agreement/agreement-details.service'; 
import { LoaderInterceptorService } from './shared/loader-interceptor.service'; 
import { ContractComponent } from './contract/contract.component'; 
import { EditableControlComponent } from './shared/editable-control/editable-control.component'; 
import { SearchService } from './home/search.service'; 
import { FilesComponent } from './agreement/files/files.component'; 
import { SearchComponent } from './home/search/search.component'; 

@NgModule({ 
    imports: [ 
     BrowserModule, 
     FormsModule, 
     ReactiveFormsModule, 
     HttpClientModule, 
     MultiselectDropdownModule, 
     FileUploadModule, 
     SlimLoadingBarModule.forRoot(), 
     AppRoutingModule, 
     PagingUtilitiesModule.forRoot() 
    ], 
    declarations: [ 
     AppComponent, 
     HomeComponent, 
     LoginComponent, 
     AgreementComponent, 
     DatepickerDirective, 
     HeaderComponent, 
     CreatePriceListComponent, 
     ContractComponent, 
     EditableControlComponent, 
     FilesComponent, 
     SearchComponent 
    ], 
    providers: [ 
     { 
      provide: HTTP_INTERCEPTORS, 
      useClass: LoaderInterceptorService, 
      multi: true 
     }, 
     ExcelReaderService, 
     AgreementDetailsService, 
     SearchService, 
     Location 
    ], 
    bootstrap: [AppComponent] 
}) 

export class AppModule { } 

あなたが見ることができるように、OrderByPipeFilterPipeはパイプであり、私は私のPagingUtilitiesModuleでそれらを提供していると私は私のPagingUtilitiesModule.forRoot()AppModuleへのインポートをしています。ファイルの変更時に発生する通常のビルドでうまくいきます。私はng build --prodを行うときには、それは

ERROR in Error: Cannot determine the module for class OrderByPipe in D:/Projects/AMSSFrontEnd/src/app/shared/paging-utilities/order-by.pipe.ts! Add OrderByPipe to the NgModule to fix it. Cannot determine the module for class FilterPipe in D:/Projects/AMSSFrontEnd/src/app/shared/paging-utilities/filter.pipe.ts! Add FilterPipe to the NgModule to fix it.

はこれで私を助けてください、このエラーを示しています。あなたは以下のようにexport[]プロパティにFilterPipeOrderByPipeパイプを追加しようとすることができます

答えて

0

exports: [ 
    FilterPipe, 
    OrderByPipe, 
    SortByDirective, 
    PaginationComponent 
] 

・ホープこのヘルプ!

関連する問題