如果文本框值放在http中,下面的代码不能正确设置文本框值。文本框值与占位符的值重叠。
this.http.get('tes.json')
.map(response => response.json())
.subscribe(result => {
(<FormGroup>this.form)
.setValue({food: "test", food1: '123123'}}, {onlySelf: true});
});下面是演示该问题的柱塞https://plnkr.co/edit/aKZZ9vLLykVSMf3oqFEg?p=preview和下图

但是,如果我们在http之外设置formgroup值,就可以正常工作,如下所示。
(<FormGroup>this.form)
.setValue({food: "test", food1: '123123'}}, {onlySelf: true});谁能告诉我是什么导致了这个问题??
发布于 2017-01-06 17:35:00
未加载您的this作用域。
let _self = this;
this.http.get('tes.json')
.map(response => response.json())
.subscribe(result => {
(<FormGroup>_self.form)
.setValue({food: "test", food1: '123123'}}, {onlySelf: true});
});发布于 2017-01-11 23:02:50
该问题是由新的mdInput实现引起的。在下一版本的(2.0.0-beta.2).中将有一个修复
你可以..。
<md-input>元素,直到新版本发布。当你对导致这个问题的原因感兴趣时,this pull request应该已经解决了这个问题。
发布于 2017-08-30 20:28:46
在beta.10中仍然存在这个问题。
如果我点击表单中的一个输入..它修复了该表单中的所有输入
..。我现在的解决方法是为输入调用click事件
https://stackoverflow.com/questions/41502601
复制相似问题