如何在Angular 4中实现当您在复选框中注册时保存"A"或"B"值.尽我所能,他只是送我真假,我希望有人可以帮助我.
registry.component.ts
this.userForm = new FormGroup({
state: new FormControl('',),
});
Run Code Online (Sandbox Code Playgroud)
registry.component.html
<div class="form-group">
<label>State</label>
<input type="checkbox" [(ngModel)]="isChecked" (change)="checkValue(isChecked?'A':'B')" formControlName="state"/>
</div>
<pre>{{userForm.value | json}}</pre>
Run Code Online (Sandbox Code Playgroud)
这样我可以让控制台显示我想要的值(A或B),但在JSON中仍然是真或假.