我想完全理解在angular 7+中.value和.setValue之间有什么区别,在哪种情况下适合使用.value或.setValue?
示例1:this.createLocForm.setValue(data);
示例2:this.data = this.createLocForm.value
最佳答案
示例1:this.createLocForm.setValue(data);
Use the setValue() method to set a new value for individual control. The setValue() method strictly adheres to the structure of the form group and replaces the entire value for the control. Please read this for more details
示例2:this.data = this.createLocForm.value
This is a read-only property. You can't assign any value for this property. You can only do read the control values by using this property.
关于angular - Angular 7+中 react 形式的.value和.setValue之间的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59588097/