如何从Angular Js中的结果数据中删除空格

时间:2018-11-14 09:00:09

标签: angularjs angular

我试图在绑定控件中删除空白。如何删除空白?

 this.addressInfo.patchValue({
   street: result.data['street'],
   houseNumber: result.data['houseNo'],
   city: result.data['city'],
   country: result.data['country'],
   zipCode: result.data['postalCode']
 });

1 个答案:

答案 0 :(得分:0)

我找到了简单的解决方案。只需使用.trim()关键字。

 this.addressInfo.patchValue({
                        street: result.data['street'].trim(),
                        houseNumber: result.data['houseNo'].trim(),
                        city: result.data['city'].trim(),
                        country: result.data['country'].trim(),
                        zipCode: result.data['postalCode'].trim()
                    });