を使用して、容易に複数のコントロールの値を変更上記の別のフォームコントロール。彼らが他のものを選択すると、その行の値だけが変更されます。私はこのテーブルを有するアンギュラ/活字体
だから、今のように、ここで私は、これらの変更を処理しています方法です:私のngOnInit
で
:
this.form.controls['selectAll']
.valueChanges
.distinctUntilChanged()
.subscribe(data => {
this.selectAll();
});`
と私のselectAll
機能:
selectAll() {
let depthValue = this.form.controls['depth'].value;
if (this.form.controls['selectAll'].value === true) {
this.form.controls['index44'].setValue(depthValue);
this.form.controls['index4'].setValue(depthValue);
this.form.controls['index5'].setValue(depthValue);
this.form.controls['index6'].setValue(depthValue);
this.form.controls['index7'].setValue(depthValue);
this.form.controls['index8'].setValue(depthValue);
this.form.controls['index9'].setValue(depthValue);
this.form.controls['index10'].setValue(depthValue);
this.form.controls['index13'].setValue(depthValue);
this.form.controls['index14'].setValue(depthValue);
this.form.controls['index15'].setValue(depthValue);
this.form.controls['index16'].setValue(depthValue);
this.form.controls['index17'].setValue(depthValue);
this.form.controls['index18'].setValue(depthValue);
this.form.controls['index19'].setValue(depthValue);
this.form.controls['index20'].setValue(depthValue);
this.form.controls['index21'].setValue(depthValue);
//etc
}
だから私の質問は:これらのボックスすべてに値を適用する方が簡単で簡単な方法があるので、単純に値に変更するために何百行ものコードを用意する必要はありませんナンバーボックスの?
まさに私が探していたもの!ありがとうございました! – CodyCS