2016-04-04 79 views
2

我見過很多人有這個問題,與angular2-polyfills.js有關的解決方案。我已經包括我的WebPack這個文件,但是:Webpacked Angular2應用類型錯誤:無法讀取undefined屬性'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 {} 

編輯 這可能跟我的使用玉裝載機做;當我切換到需要原始的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份在同一個地方運行會出現這種情況。之前是系統填充。

我在同一時間包含zone.js時遇到了同樣的問題。當兩個區域都監視所有的保證呼叫時,它們會互相反彈並導致堆棧溢出。

角度填充總是包含ng自己的區域實現。 zone.js不應該單獨加載。

相關問題