【发布时间】:2020-05-19 06:46:24
【问题描述】:
我正在使用Angular Wrapper 来表示JSON Editor,如下所示:
<div *ngFor="let act of editedActions" class="w-100-p p-24">
{{act.test_step_id}}
<json-editor [options]="editorOptions" [(data)]="act.action_json" [(eventParams)]="act.test_step_id" (jsonChange)="changeStepActions($event)"></json-editor>
<button mat-raised-button class="w-100-p mt-24" color="primary" (click)="editRecordJson(act.test_step_id)">
<span>Update</span>
</button>
</div>
问题是eventParams 对于每个编辑器应该是不同的,但它并没有变化。
我认为问题是这个组件代码(但不确定)(这一行是在从 github 获取的组件中):
@ViewChild('jsonEditorContainer', { static: true }) jsonEditorContainer: ElementRef;
组件表现得像一个单例。有什么帮助吗?
编辑:我编辑了这个 repo 并添加了 jsonchange 事件。详情here
【问题讨论】:
-
你在模板中哪里定义了
jsonEditorContainer,我看不到。此外,如果您想在ngFor中使用多个实例,您应该使用 ViewChildren -
在github链接的组件中定义:github.com/mariohmol/ang-jsoneditor/blob/master/ang-jsoneditor/…
-
什么是
eventParams?是ang-jsoneditor的输入\输出吗?自定义指令?我找不到任何关于它的信息。 -
我对其进行了编辑以尝试是否可以通过手动传递给事件来获取参数。 editRecordJson 事件也是如此。
标签: javascript angular angular-components