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)