我正在尝试绑定数组中的离子输入,但是当我想更改屏幕上的值时,输入会消失。我的意思是,如果我将指针放入文本区域,指针就会消失,我必须重新放入。
但是,如果我删除[(ngModel)],指针永远不会消失。
这里我让离子输入的代码。
<ion-col *ngFor="let x of totalExercices[ex].maquina.repeticions; let ma = index;">
<ion-input type="number"
[(ngModel)]="totalExercices[ex].maquina.repeticions[ma]"
style="background-color:#f4f4f4;">
</ion-input>
</ion-col>
在下面的图像中,如果我们修复元素20.如果我想删除数字,当0消失时,指针也会消失。
看起来像这样: Deleted the 0, but I have to put again the pointer there.
正如我所说,我猜问题是ngModel。
也许还有其他一些方法可以改变输入的值,而不是ngModel?
非常感谢你!
答案 0 :(得分:0)
嗯,在搜索问题之后,我找到了解决方案。如果我们使用数组绑定NgModel,它每次都会加载,因此每次我们进行一些更改时都会重新加载列表。 解决方案是跟踪请参阅以下链接中的解决方案: