私は反応するフォームを持っています。私はコントロールを無効にして編集します。フォームコントロールは無効にするが、値を保持する方法
以下の作品は:
this.myForm.controls['analysis_horizon'].disable();
しかし、キーanalysis_horizonは私のmyForm.valueハッシュではなくなり。
どのように反応形式のフィールドを無効にしますが、フォーム値のハッシュ値を保持するにはどうすればよいですか?
私は[無効]を試みた=が、私は以下の取得:
It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true
when you set up this control in your component class, the disabled attribute will actually be set in the DOM for
you. We recommend using this approach to avoid 'changed after checked' errors.
Example:
form = new FormGroup({
first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
last: new FormControl('Drew', Validators.required)
});
私はフォームコントロールに編集上の私のデータベースからデータをロードするが、私は変更することは許されない1つのフィールドを必要としています。
。 – micronyks
それは変更されていないことを考えれば、それを消費しているものであれば、Object.assignなどで値を自分自身に戻すことができます。 – jonrsharpe
私は誤解しているかもしれませんが、メッセージが示唆しているようにしてください: 'yourFormControl:new FormControl({value:yourPresetValue、disabled:true})' – Alex