2017-10-08 7 views
1

私はイオンヴァランアンドロイド--deviceを実行するが、ときの作業のアプリは、私は、イオンヴァランアンドロイド--prodは私がしようとしていますレイジー(イオン)が

を--releaseしようとエラーが発生します

:私の怠惰なロードされたページ

Error: Unexpected value 'QRCodeComponent in D:/qrstore/node_modules/ng2-qrcode/dist/ng2-qrcode.d.ts' declared by the module 'ItemDetailPageModule in D:/qrstore/src/pages/item-detail/item-detail.module.ts'. Please add a @Pipe/@Directive/@Component annotation. at Error (native) at syntaxError (D:\qrstore\node_modules\@angular\compiler\bundles\compiler.umd.js:1729:34) at D:\qrstore\node_modules\@angular\compiler\bundles\compiler.umd.js:15625:40 at Array.forEach (native) at CompileMetadataResolver.getNgModuleMetadata (D:\qrstore\node_modules\@angular\compiler\bundles\compiler.umd.js:15607:54) at addNgModule (D:\qrstore\node_modules\@angular\compiler\bundles\compiler.umd.js:24403:58) at D:\qrstore\node_modules\@angular\compiler\bundles\compiler.umd.js:24414:14 at Array.forEach (native) at _createNgModules (D:\qrstore\node_modules\@angular\compiler\bundles\compiler.umd.js:24413:26) at analyzeNgModules (D:\qrstore\node_modules\@angular\compiler\bundles\compiler.umd.js:24288:14)

イオン性情報

@ionic/cli-utils : 1.12.0 
ionic (Ionic CLI) : 3.12.0 

グローバルパッケージにNG2-QRコードを使用します

ローカルパッケージ:

@ionic/app-scripts : 3.0.0 
Cordova Platforms : android 6.2.3 
Ionic Framework : ionic-angular 3.7.1 

システム:

Android SDK Tools : 25.2.3 
Node    : v6.9.4 
npm    : 3.10.8 
OS    : Windows 10 

その他:

backend : pro 

アイテムの詳細モジュール

import { NgModule } from '@angular/core'; 
import { IonicPageModule } from 'ionic-angular'; 
import { ItemDetailPage } from './item-detail'; 
import { HttpModule, Http } from '@angular/http'; 

//native 
import { File } from '@ionic-native/file'; 
import { FilePath } from '@ionic-native/file-path'; 
import { SQLite } from '@ionic-native/sqlite'; 

//providers 
import { ItemsProvider, LabelsProvider, SQLiteDatabaseProvider } from '../../providers/providers'; 

//components 
import { ItemCreatePage } from '../item-create/item-create'; 
import { QRCodeComponent } from 'ng2-qrcode' 

//directive 
import { AbsoluteDragDirective } from '../../directives/absolute-drag/absolute-drag'; 

@NgModule({ 
    declarations: [ 
    ItemDetailPage, 
    QRCodeComponent, 
    AbsoluteDragDirective 
    ], 
    imports: [ 
    IonicPageModule.forChild(ItemDetailPage), 
    HttpModule 
    ], 
    exports: [ 
    ItemDetailPage 
    ], 
    entryComponents: [] 
    , 
    providers:[ 
    ItemsProvider, 
    SQLite, 
    SQLiteDatabaseProvider, 
    File, 
    FilePath 
    ] 
}) 
export class ItemDetailPageModule {} 

答えて

2

ng2-qrcodeは、もはや維持されておらず、角度のAoTコンパイラ(--prodでアプリケーションをビルドするときに使用されます)では動作しません。しかし、AoTコンパイラを使用するIonic3/Angular4 +プロジェクトでは、angularx-qrcodeでの使用のために構築された置換えの低下があります。これは同じライブラリに基づいており、同じAPIを提供します。

npm install angularx-qrcode --save 

そして、それはあなたのNgModuleでそれをインポート使用する:

次のようにそれを追加

import { QRCodeModule } from 'angularx-qrcode'; 

そしてimports配列に追加します。

imports: [ 
    QRCodeModule 
], 
+0

良い情報+1。 1つの質問:「Angular 4」以上を使用して開発しないAngularコンポーネントは使用できないのでしょうか?言い換えれば、最新の「イオン3」と「AOT」の「角度2」成分を使用することはできませんか? – Sampath

+2

ありがとうサム!あなた自身のプロジェクトにコピーを貼り付けると、コンポーネント自体は問題ありません。正常に動作するはずです。問題はライブラリがどのように公開されたかです。Angular2ライブラリをngc(角モードのコンパイラで事前に実行されていた)で動作させるためには、いくつかの変更が必要です(例:* .d.tsファイル、* .metadata.jsonファイルが必要です)。あなたはそれについてもっと読むことができます[ここ](https://medium.com/@isaacplmann/getting-your-angular-2-library-ready-for-aot-90d1347bcad)。したがって、ほとんどのコンポーネントはAngular4/Ionic3で動作するはずですが、これは維持されていないため、これは動作しません。 – David