Webpacked Angular2应用程序TypeError:无法读取未定义的属性“ getOptional”

用户名

我见过很多人遇到这个问题,并提出了与angular2-polyfills.js相关的解决方案。但是,我已经在Webpack中包含了此文件:

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 {}

编辑这可能与我对jade-loader的使用有关;当我切换到需要原始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)
阿诺德·吉茨(Arnold Jits)

当区域中有2个副本在同一位置运行时,会发生这种情况。以前是system-polyfill。

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

angular-polyfill始终包含ng自己的区域实现。zone.js不应单独加载。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

从外部调用Webpacked代码(HTML脚本标记)

Angular2:无法读取未定义的属性“名称”

angular2:错误:TypeError:无法读取未定义的属性“ ...”

未定义的polyfill的Angular2 getOptional

Angular2:TypeError:无法读取未定义的属性“ Symbol(Symbol.iterator)”

Angular2无法读取未定义的属性“ push”

无法读取未定义[Angular2]的属性“ isStopped”

Google Picker API + Angular2收到未捕获的TypeError:无法读取未定义的属性'handleAuthResult'

Angular 2 TypeError:无法读取未定义的属性“ toUpperCase”

无法读取未定义angular2的属性

使用Angular2中的动态组件时出现错误“错误TypeError:无法读取未定义的属性'createComponent'”

TypeError:在angular2中执行单元测试时,无法读取未定义故障的属性“快照”

如何在Elastic Beanstalk容器中提供Rails应用程序的Webpacked资产?

NgZone / Angular2 / Ionic2 TypeError:无法读取未定义的属性“运行”

未捕获的TypeError:无法读取reactjs应用程序中未定义的属性'map'

Typescript / Angular2 TypeError:无法读取未定义的属性

Titanium无法编译Android应用程序(无法读取未定义的属性'sdks')

TypeError:无法读取angular2中未定义的属性“ 0”以在datepicker中使用索引

Node.js需要Webpacked模块

无法启动应用程序。TypeError:无法读取getFieldsJsonSchemaFor中未定义的属性“ definition”

React.js应用程序中的Mapbox-gl,TypeError:无法读取未定义的属性“ setFeatureState”

应用程序脚本错误:无法读取未定义的属性“ length”

TypeError:无法读取角度应用程序中未定义的属性“ 0”

如何修复角度2错误无法读取属性“ getOptional”?

ie9中的Angular 1/2混合应用程序错误:“ TypeError:无法获取属性'ref'的值:对象为null或未定义”

类型错误:无法读取 Angular 应用程序中未定义的属性“长度”

导出静态 NextJS 应用程序`TypeError:无法读取未定义的属性'/404'

应用程序在 UNMOUNTING 状态下死亡:无法读取未定义的属性“注入器”

反应问题无法在测验应用程序中读取未定义的属性(读取“地图”)?