首页 > 解决方案 > 如何使输入更改 ngFor 项目值?

问题描述

例如,我有这个数组(从开发工具中的 Sources 选项卡获得)

bodyParams = [
 0: {placeholder: "{{1}}"}
 1: {placeholder: "{{2}}"}
 2: {placeholder: "{{3}}"}
 3: {placeholder: "{{4}}"}
 4: {placeholder: "{{5}}"}
]

而这个 ngFor:

<div *ngFor="let item of bodyParams; let idx = index;">
    <wds-input
    [placeholder]="
        ('messages.generic.message_composer.template.sample_insert' | translate) + '{{' + (idx + 1) + '}\}'
    "
    ></wds-input>
</div>

对于每个项目,ngFor 生成一个输入字段来填充..

但我不能让输入值更改数组占位符值来进行替换。

我尝试使用[(ngModel)]但没有用。

标签: javascriptangulartypescript

解决方案


推荐阅读