如何找出受影响的组件名称是什么?我真的不明白为什么angular会说“ class_1”是组件名称。我正在使用Angular 7.0.0,并且正在进行重构。 (将6个组件添加到一个新模块中)
Error: Uncaught (in promise): Error: Component class_1 is not part of any NgModule or the module has not been imported into your module.
Error: Component class_1 is not part of any NgModule or the module has not been imported into your module.
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._createCompiledHostTemplate (compiler.js:24520)
at compiler.js:24496
at Array.forEach (<anonymous>)
at compiler.js:24493
at Array.forEach (<anonymous>)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:24482)
at compiler.js:24410
at Object.then (compiler.js:1012)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:24409)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.compileModuleAsync (compiler.js:24369)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._createCompiledHostTemplate (compiler.js:24520)
at compiler.js:24496
at Array.forEach (<anonymous>)
at compiler.js:24493
at Array.forEach (<anonymous>)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:24482)
at compiler.js:24410
at Object.then (compiler.js:1012)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:24409)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.compileModuleAsync (compiler.js:24369)
at resolvePromise (zone.js:814)
at resolvePromise (zone.js:771)
at zone.js:873
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:13842)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
at drainMicroTaskQueue (zone.js:595)
at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:500)
at invokeTask (zone.js:1540)
答案 0 :(得分:0)
我已经解决了这个问题。我删除了路由文件中的每条路由,然后逐一添加,发现模块声明中缺少1个组件。但是我真的不明白为什么angular会说组件名称是“ class_1”,但是我意识到受影响的组件在另一个模块中,因为有2个组件具有相同的名称,而我尝试使用错误的组件。因此,我假设angular在另一个模块中无法获得受影响的组件名称。