2017-04-07 1 views
1

이온 2 프로젝트를 최신 버전 (3.0.0)으로 마이그레이션했습니다. 모든 것이 완벽해질 때까지 오늘 프로젝트에서 새 페이지 (DiscountOption)를 생성했습니다. 3 대신에 4 개의 파일을 생성했습니다 (* .module.ts는 새로운 파일 임).이온 2 프로젝트를 만들 수 없습니다

할인-option.module.ts

import { NgModule } from '@angular/core'; 
import { IonicPageModule } from 'ionic-angular'; 
import { DiscountOption } from './discount-option'; 

@NgModule({ 
    declarations: [ 
    DiscountOption, 
    ], 
    imports: [ 
    IonicPageModule.forChild(DiscountOption), 
    ], 
    exports: [ 
    DiscountOption 
    ] 
}) 
export class DiscountOptionModule { } 

app.module.ts

... 
import { DiscountOption } from '../pages/orders/biller/discount-option/discount-option'; 

@NgModule({ 
    declarations: [ 
    ... 
    DiscountOption 
    ], 
    imports: [ 
    BrowserModule, 
    HttpModule, 
    IonicModule.forRoot(MyApp), 
    IonicStorageModule.forRoot() 
    ], 
    bootstrap: [IonicApp], 
    entryComponents: [ 
    ... 
    DiscountOption 
    ], 
    providers: [ 
    ... 
    ] 
}) 
export class AppModule { } 

(... 코드를 간결 단축)

: 여기

내 코드입니다

ionic build android --prod

를 사용하여 앱을 만들려고했는데

나는

[11:35:52] ionic-app-script task: "build" 
[11:35:52] Error: Type DiscountOption in E:/TFS 
      SOURCE/HMS/HMS.App/eKot/src/pages/orders/biller/discount-option/discount-option.ts is part of the 
      declarations of 2 modules: AppModule in E:/TFS SOURCE/HMS/HMS.App/eKot/src/app/app.module.ts and 
      DiscountOptionModule in E:/TFS 
      SOURCE/HMS/HMS.App/eKot/src/pages/orders/biller/discount-option/discount-option.module.ts! Please consider 
      moving DiscountOption in E:/TFS 
      SOURCE/HMS/HMS.App/eKot/src/pages/orders/biller/discount-option/discount-option.ts to a higher module that 
      imports AppModule in E:/TFS SOURCE/HMS/HMS.App/eKot/src/app/app.module.ts and DiscountOptionModule in E:/TFS 
      SOURCE/HMS/HMS.App/eKot/src/pages/orders/biller/discount-option/discount-option.module.ts. You can also 
      create a new NgModule that exports and includes DiscountOption in E:/TFS 
      SOURCE/HMS/HMS.App/eKot/src/pages/orders/biller/discount-option/discount-option.ts then import that NgModule 
      in AppModule in E:/TFS SOURCE/HMS/HMS.App/eKot/src/app/app.module.ts and DiscountOptionModule in E:/TFS 
      SOURCE/HMS/HMS.App/eKot/src/pages/orders/biller/discount-option/discount-option.module.ts. 
Error: Type DiscountOption in E:/TFS SOURCE/HMS/HMS.App/eKot/src/pages/orders/biller/discount-option/discount-option.ts is part of 
the declarations of 2 modules: AppModule in E:/TFS SOURCE/HMS/HMS.App/eKot/src/app/app.module.ts and DiscountOptionModule in E:/T 
FS SOURCE/HMS/HMS.App/eKot/src/pages/orders/biller/discount-option/discount-option.module.ts! Please consider moving DiscountOptio 
n in E:/TFS SOURCE/HMS/HMS.App/eKot/src/pages/orders/biller/discount-option/discount-option.ts to a higher module that imports App 
Module in E:/TFS SOURCE/HMS/HMS.App/eKot/src/app/app.module.ts and DiscountOptionModule in E:/TFS SOURCE/HMS/HMS.App/eKot/src/page 
s/orders/biller/discount-option/discount-option.module.ts. You can also create a new NgModule that exports and includes DiscountOp 
tion in E:/TFS SOURCE/HMS/HMS.App/eKot/src/pages/orders/biller/discount-option/discount-option.ts then import that NgModule in App 
Module in E:/TFS SOURCE/HMS/HMS.App/eKot/src/app/app.module.ts and DiscountOptionModule in E:/TFS SOURCE/HMS/HMS.App/eKot/src/page 
s/orders/biller/discount-option/discount-option.module.ts. 
at Error (native) 
    at syntaxError (E:\TFS SOURCE\HMS\HMS.App\eKot\node_modules\@angular\compiler\bundles\compiler.umd.js:1513:34) 
    at CompileMetadataResolver._addTypeToModule (E:\TFS SOURCE\HMS\HMS.App\eKot\node_modules\@angular\compiler\bundles\compiler.um 
d.js:14118:31) 
    at E:\TFS SOURCE\HMS\HMS.App\eKot\node_modules\@angular\compiler\bundles\compiler.umd.js:14007:27 
    at Array.forEach (native) 
    at CompileMetadataResolver.getNgModuleMetadata (E:\TFS SOURCE\HMS\HMS.App\eKot\node_modules\@angular\compiler\bundles\compiler 
.umd.js:13998:54) 
    at addNgModule (E:\TFS SOURCE\HMS\HMS.App\eKot\node_modules\@angular\compiler\bundles\compiler.umd.js:22526:58) 
    at E:\TFS SOURCE\HMS\HMS.App\eKot\node_modules\@angular\compiler\bundles\compiler.umd.js:22537:14 
    at Array.forEach (native) 
    at _createNgModules (E:\TFS SOURCE\HMS\HMS.App\eKot\node_modules\@angular\compiler\bundles\compiler.umd.js:22536:26) 

은이 오류로 인해 두 번 app.module에서 모듈 및 새로 생성 된 모듈 파일을 선언하는 것입니다 알고,이 오류가 발생합니다. 어떻게 작동시키는 지 모르겠습니다. 조언이 도움이 될 것입니다. 고맙습니다.

은 여기 내 이온 정보

E입니다 : \ TFS SOURCE \ HMS \ HMS.App \ eKot> 이온 성 정보

시스템 정보 :

Cordova CLI: 6.5.0 
Ionic Framework Version: 3.0.0 
Ionic CLI Version: 2.2.2 
Ionic App Lib Version: 2.2.1 
Ionic App Scripts Version: 1.3.0 
ios-deploy version: Not installed 
ios-sim version: Not installed 
OS: Windows 10 
Node Version: v6.10.0 
Xcode version: Not installed 

답변

2

google docs regarding ionic v3을 확인합니다.

DiscountOption10 페이지에 대한 참조를 모두 app.module.ts에서 삭제하십시오.

@NgModule({ 
    declarations: [ 
    ... 
    ], 
    imports: [ 
    BrowserModule, 
    HttpModule, 
    IonicModule.forRoot(MyApp), 
    IonicStorageModule.forRoot() 
    ], 
    bootstrap: [IonicApp], 
    entryComponents: [ 
    ... 
    ], 
    providers: [ 
    ... 
    ] 
}) 
export class AppModule { } 
페이지가 참조하고 page.module.ts

당신이 @IonicPage()를 추가 name.Also 클래스의 캐릭터 상당하는 .. 제거 다른 곳 페이지를 가져 오는 경우에 선언됩니다

DiscountOption에서

@IonicPage() 
@Component({ 
    templateUrl: 'discount-option.html' 
}) 
export class DiscountOption {} 

참조 : 당신이 유를하지 않은 경우 IonicPage

+0

응답 해 주셔서 감사합니다. 참조를 제거했으며 프로젝트가 작성되었습니다. 하지만 장치에서 실행하면 페이지가 표시되지 않습니다. 브라우저에서 서비스 할 때 콘솔에 'DiscountOption에 대한 구성 요소 팩터 리 없음'오류가 표시됩니다. @ NgModule.entryComponents에 추가 했습니까? '. 나는 대답과 직접적으로 모순되는 app.module.ts에서 그것을 참조 할 필요가있다! –

+0

app.component.ts에서 페이지를 가져 왔습니까? –

+0

app.component.ts 또는 app.module.ts가 맞습니까? –

1

이오니아 3 레이지로드 기능을 사용하면 페이지의 yourPage.module.ts 만 제거하면됩니다. (선택 사항)입니다.

+0

게으른 로딩 기능에 대해 어떻게 생각하십니까? –

+0

이 문서를 참조하십시오. https : //docs.google.com/document/d/1vGokwMXPQItZmTHZQbTO4qwj_SQymFhRS_nJmiH0K3w/edit#heading=h.yw70uq35xyz8 @suraj – Sampath

+0

읽었습니다 .. 내 답변에서 참조했습니다. .. 확실하지 않습니다. 모든 페이지/구성 요소를 자체 모듈로 변환하는 것에 대해 .. –