gpt4 book ai didi

angular - Angular 7+中 react 形式的.value和.setValue之间的差异

转载 作者:行者123 更新时间:2023-12-01 10:17:45 26 4
gpt4 key购买 nike

我想完全理解在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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com