我对角度和打字稿很陌生,并试图了解此方法中到底发生了什么:
updatePostcode() {
this.FilterService.updatePostcode({
postcode: this.regionFormGroup.get('hasPostcode').value ?
this.regionFormGroup.get('postcode').value : undefined
})
this.regionFormGroup.get('postcode').reset()
}
Run Code Online (Sandbox Code Playgroud)
好的,这是更新邮政编码的方法。
this.regionFormGroup.get('hasPostcode').value?undefined意思?( : undefined)问题是,如果调用 updatePostcode 方法,表单将被重置,并且用户输入的邮政编码将被替换为任何内容。