我现在将我的项目从Angular版本5.2升级到Angular版本7.2。我运行了以下命令:
将所有角度包package.json升级到〜7.2.0
升级@ angular / cli
Chrome 68.0.3440(Windows 8.1.0.0)NdvAction ndv !!!! 失败错误:无法解析ApplicationModule的所有参数:(?)。在语法错误node_modules/@angular/compiler/fesm5/compiler.js:2426:1)在CompileMetadataResolver.push ../ node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata node_modules / @ angular / com /compiler.js:18979:1)位于CompileMetadataResolver.push ../ node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata node_modules/@angular/compiler/fesm5/compiler.js:18872:1) CompileMetadataResolver.push ../ node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata node_modules/@angular/compiler/fesm5/compiler.js:18740:1)在CompileMetadataRenoder.push。 /compiler/fesm5/compiler.js。http:// localhost:9876 / _karma_webpack_ / webpack:/node_modules/@angular/compiler/fesm5/compiler.js:18664:1在Array.forEach()在CompileMetadataResolver.push ../ node_modules / @ angular / compiler / fesm5 /compiler.js.CompileMetadataResolver.getNgModuleMetadata node_modules/@angular/compiler/fesm5/compiler.js:18652:1)在CompileMetadataResolver.push ../ node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadata @ angular / compiler / fesm5 / compiler.js:18550:1)Chrome 68.0.3440(Windows 8.1.0.0):执行395之1(1失败)(跳过394)错误(0.527秒/0.038秒)
我可以在项目本身上重现该问题,不能在一个空项目中重现该问题,我创建了一个空服务:
import { Injectable } from '@angular/core';
@Injectable()
export class NdvAction {
}
Run Code Online (Sandbox Code Playgroud)
一个空的测试用例:
import { …Run Code Online (Sandbox Code Playgroud) 我最近开始使用角度V6发布的角度元素,我开了一个小沙盒项目. https://github.com/Slash7GNR/ndv-angular-elements 现在我试图向我的web组件添加一个更复杂的输入 - 我试图按如下方式添加数组输入:在app.component.ts中我添加了:
@Input() welcomeMessages: string[];
Run Code Online (Sandbox Code Playgroud)
在我添加的模板中:
<div *ngFor="let message of welcomeMessages; let index = index">
{{index}} - {{message}}
</div>
Run Code Online (Sandbox Code Playgroud)
然后,我创建了一个静态html文件并添加了以下代码:(pls-wrk是由角元素功能生成的Web组件)
<pls-wrk></pls-wrk>
<script>
let arr = [“wow”,”wow2"];
let elementByTag = document.getElementsByTagName(‘pls-wrk’)[0];
elementByTag.setAttribute(“welcome-messages”, arr);
</script>
<script src="ndv-elements.js"></script>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
未捕获的错误:无法找到'string'类型的不同支持对象'哇,哇'.NgFor仅支持绑定到诸如Arrays之类的Iterables.
我也试过通过元素本身绑定数组,如下所示:
<pls-wrk welcome-messages=”[‘wow’,wow2']”></pls-wrk>
Run Code Online (Sandbox Code Playgroud)
但这都不奏效.
我也试过绑定一个作为对象的输入,但我在html中看不到结果.
这里的任何人都可以成功地将数组/对象作为输入传递给角元素?