0
submit하기 전에 객체에서 "장난감"을 form.value에서 삭제하고 '가격'에 새 데이터를 추가해야합니다. 그러나 컨트롤을 선언해야합니다.각도 2는 form.value 객체에 데이터를 제거하거나 추가합니다.
form.value 객체
{
"red": 1,
"green": 3,
"black": "120",
"blue": 3,
"toys": [
{
"bear": 0,
"soldier": 0,
"car": 0
}
],
"price": [
{
"default": 123,
"pre": 3,
"after": 2
},
{
"default": 3,
"pre": 0,
"after": 0
}
]
}
TS
initForm() {
this.form = this._fb.group({
red: 0,
green: 0,
black: '',
blue: 0,
toys: this._fb.array([this.inittoys()]),
price: this._fb.array([this.initprice()]),
});
HTML
<div class="form-group">
<label for="black">Max travel time</label>
<select class="form-control" id="black" formControlName="black">
<option *ngFor="let t of colors; let i=index" [ngValue]="i">{{t}}</option>
</select>
</div>
:
.... 구성 요소에
를 https : //로 유래 .com/questions/41852183/angular-2-remove-all-items-from-a-formarray. 배열을 패치하려면 https://stackoverflow.com/questions/39229398/how-to-update-controls-of-formarray 다음 번에 Google에 시도하십시오.) – Swoox
나에게 수치 스럽습니다. 감사, –