当我尝试使用具有使用angular-element
的自定义组件的模块时,出现此错误。
我尝试在我的应用中将该模块用作CoreModule.forRoot()
。它已经导出了组件,这些相同的组件被列为输入组件和自定义组件。
当我深入到代码时,我发现下面生成的javascript行导致了错误。
customElements.define('cfheader', Object(_angular_elements__WEBPACK_IMPORTED_MODULE_12__["createCustomElement"])(HeaderComponent, { injector: injector }));
...
源代码中的同一行用角表示
customElements.define('cf-header', createCustomElement(HeaderComponent, {injector}));
...
错误消息:
DOMException: Failed to execute 'define' on 'CustomElementRegistry': "cfheader" is not a valid custom element name
at new CoreModule (http://localhost:4200/vendor.js:68177:24)
at _createClass (http://localhost:4200/vendor.js:43333:20)
at _createProviderInstance$1 (http://localhost:4200/vendor.js:43303:26)
at initNgModule (http://localhost:4200/vendor.js:43239:32)
at new NgModuleRef_ (http://localhost:4200/vendor.js:43962:9)
at createNgModuleRef (http://localhost:4200/vendor.js:43951:12)
at Object.debugCreateNgModuleRef [as createNgModuleRef] (http://localhost:4200/vendor.js:45776:12)
at NgModuleFactory_.push../node_modules/@angular/core/fesm5/core.js.NgModuleFactory_.create (http://localhost:4200/vendor.js:46478:25)
at http://localhost:4200/vendor.js:39376:43
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:4200/polyfills.js:2704:26)