角反应式表单值未在表单数组推送上更新

时间:2018-10-01 18:08:08

标签: angular angular-reactive-forms

我尝试了使用formarray的嵌套表单控件,并且如果我更改了现有的显示值,它将更新表单值。但是,我尝试在formarray中添加一个表单组,其内容显示在UI中,而不是表单值(JSON)。我已经将代码发布在stackblitz中。预先感谢。

https://stackblitz.com/edit/angular-nested-forms-reactive-vvczmt

1 个答案:

答案 0 :(得分:3)

在您的html中,如果您使用<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" app:srcCompat="@mipmap/ic_launcher" android:layout_gravity="center" android:layout_margin="20dp"/> <TextView android:id="@+id/nameLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" android:layout_margin="20dp" android:text="Name" android:layout_weight="1" /> <CheckBox android:id="@+id/checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:focusable="false" android:focusableInTouchMode="false" android:layout_gravity="right|center" android:gravity="right|center" /> <CheckBox android:id="@+id/checkbox2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:focusable="false" android:focusableInTouchMode="false" android:layout_gravity="right|center" android:gravity="right|center" /> <CheckBox android:id="@+id/checkbox3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:focusable="false" android:focusableInTouchMode="false" android:layout_gravity="right|center" android:gravity="right|center" /> </LinearLayout> 而不是<pre> {{ form.getRawValue() | json }} </pre>,则会看到完整的对象。

相关问题