Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/437.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 网页包装的Angular2应用程序类型错误:无法读取属性';getOptional';未定义的_Javascript_Typescript_Angular_Webpack - Fatal编程技术网

Javascript 网页包装的Angular2应用程序类型错误:无法读取属性';getOptional';未定义的

Javascript 网页包装的Angular2应用程序类型错误:无法读取属性';getOptional';未定义的,javascript,typescript,angular,webpack,Javascript,Typescript,Angular,Webpack,我看到很多人都有这个问题,有一个与angular2-polyfills.js相关的解决方案。我已经将此文件包含在我的网页中,但是: entry: { 'angular2': [ 'rxjs', 'zone.js', 'reflect-metadata', 'angular2/common', 'angular2/core', 'angular2/router', 'angula

我看到很多人都有这个问题,有一个与angular2-polyfills.js相关的解决方案。我已经将此文件包含在我的网页中,但是:

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\u元素\u模式\u注册表: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)
dom\u element\u schema\u registry.ts:43未捕获异常:令牌承诺实例化期间出错!。
原始异常:RangeError:超出最大调用堆栈大小
原始堆栈跟踪:
RangeError:超出了最大调用堆栈大小
在ZoneDelegate.scheduleTask(http://localhost:3000/angular2.bundle.js:20262:28)
at Zone.scheduleMicroTask(http://localhost:3000/angular2.bundle.js:20184:41)
在scheduleResolveOrReject(http://localhost:3000/angular2.bundle.js:20480:16)
在ZoneAwarePromise.then[作为uuu zone u symbol uuu then](http://localhost:3000/angular2.bundle.js:20555:19)
按计划排队(http://localhost:3000/angular2.bundle.js:20361:63)
按计划执行微任务(http://localhost:3000/angular2.bundle.js:20369:11)
在ZoneDelegate.scheduleTask(http://localhost:3000/angular2.bundle.js:20253:23)
at Zone.scheduleMicroTask(http://localhost:3000/angular2.bundle.js:20184:41)
在scheduleResolveOrReject(http://localhost:3000/angular2.bundle.js:20480:16)
在ZoneAwarePromise.then[作为uuu zone u symbol uuu then](http://localhost:3000/angular2.bundle.js:20555:19)

当区域的两个副本在同一位置运行时,会发生这种情况。之前是系统polyfill

在同一时间包含zone.js时,我遇到了相同的问题。当两个区域都监视所有promise调用时,它们将相互反弹并导致堆栈溢出

角度多边形填充始终包含ng自己的分区实现。zone.js不应单独加载