forEach in angular modification array

问题描述 投票:0回答:1

我想用“trim()”更改这些元素的值。

“this.currentPaaas.Requisicion.RefCFinancingFirst [0] = this.currentPaaas.Requisicion [0] .RefCFinancingForm.trim();”

“this.currentPaaas.Requisicion [0] .RefCObjetoGasto = this.currentPaaas.Requisicion [0] .RefCObjetoGasto.trim();”

但它们在数组中,我这样做只会改变数组中的单个值。如何更改该数组中的所有值?

currentPaaas包含数组Requisicion []

Image Example

foreach
1个回答
0
投票

根据问题中的陈述,我认为你要做的是修剪currentPaaas中每个元素的RefCFinancingForm?

如果是,那就是你需要的:this.currentPaaas.Requisicion.forEach(x => x.RefCFinancingForm = x.RefCFinancingForm.trim())

© www.soinside.com 2019 - 2024. All rights reserved.