2016-04-04 27 views
2

この問題を抱える多くの人が、angular2-polyfills.jsに関する解決策を見てきました。私はすでにしかし、私のWebPACKでこのファイルを含めています。それにもかかわらずWebpacked Angular2 app TypeError:未定義のプロパティ 'getOptional'を読み取ることができません

entry: { 
    'angular2': [ 
     'rxjs', 
     'zone.js', 
     'reflect-metadata', 
     'angular2/common', 
     'angular2/core', 
     'angular2/router', 
     'angular2/http', 
     'angular2/bundles/angular2-polyfills' 
    ], 
    'app': [ 
     './src/app/bootstrap' 
    ] 
} 

、私のルートコンポーネントをロードしようとしたとき、私は、次のエラーを取得:

Cannot resolve all parameters for 'ResolvedMetadataCache'(?, ?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'ResolvedMetadataCache' is decorated with Injectable. 

Uncaught TypeError: Cannot read property 'getOptional' of undefined 

両方dom_element_schema_registry:43から。私は間違って何をしていますか?

以下は問題のコンポーネントファイルです。

import {Component} from 'angular2/core'; 
import {MapComponent} from './map/map.component'; 

declare var window: any; 

var $ = require('jquery'); 
window.$ = $; 
window.jQuery = $; 

@Component({ 
    selector: 'app', 
    template: require('./app.component.jade'), 
    styles: [], 
    directives: [MapComponent] 
}) 
export class AppComponent {} 

EDIT これはヒスイローダーの私の使用と関係することであってもよいです。私は生のHTMLファイルを必要に切り替えたとき、私は別のエラーを取得する:

dom_element_schema_registry.ts:43 Uncaught EXCEPTION: Error during  instantiation of Token Promise<ComponentRef>!. 
ORIGINAL EXCEPTION: RangeError: Maximum call stack size exceeded 
ORIGINAL STACKTRACE: 
RangeError: Maximum call stack size exceeded 
    at ZoneDelegate.scheduleTask  (http://localhost:3000/angular2.bundle.js:20262:28) 
    at Zone.scheduleMicroTask (http://localhost:3000/angular2.bundle.js:20184:41) 
    at scheduleResolveOrReject (http://localhost:3000/angular2.bundle.js:20480:16) 
    at ZoneAwarePromise.then [as __zone_symbol__then] (http://localhost:3000/angular2.bundle.js:20555:19) 
    at scheduleQueueDrain (http://localhost:3000/angular2.bundle.js:20361:63) 
    at scheduleMicroTask (http://localhost:3000/angular2.bundle.js:20369:11) 
    at ZoneDelegate.scheduleTask (http://localhost:3000/angular2.bundle.js:20253:23) 
    at Zone.scheduleMicroTask (http://localhost:3000/angular2.bundle.js:20184:41) 
    at scheduleResolveOrReject (http://localhost:3000/angular2.bundle.js:20480:16) 
    at ZoneAwarePromise.then [as __zone_symbol__then] (http://localhost:3000/angular2.bundle.js:20555:19) 

答えて

1

ゾーンの2つのコピーが同じ場所で実行しているとき、これが起こります。以前はシステムpolyfillでした。

zone.jsを同時に含むと同じ問題が発生します。 2ゾーンが両方ともすべての約束呼を監視すると、互いに跳ね返ってスタックオーバーフローを引き起こします。

angle-polyfillには常にng自身のゾーン実装が含まれています。 zone.jsは別々にロードしないでください。

関連する問題