@nico_nj wrote:
Hi!
I’m trying to set up a very simple reactive form using Angular7 and Ionic4, my problem is that I’m not being able to use theformControlNameon myion-radio-group. I have 2 different radio buttons and I wanted them part of the form.This is my HTML
<ion-radio-group formControlName="recipientType" required> <ion-label class="title">Send to:</ion-label> <ion-item lines="none" *ngFor="let recipient of recipientTypes"> <ion-label>{{recipient.text}}</ion-label> <ion-radio slot="start" value="recipient.text" ></ion-radio> </ion-item> </ion-radio-group>This is my component
recipientTypes = [ { text: "Group", checked: true }, { text: "Individual", checked: false }, ] constructor(private restService: RestService, private formBuilder: FormBuilder) { } ngOnInit() { this.contactForm = this.formBuilder.group({ recipientType: new FormControl('', Validators.required), topic: new FormControl('', Validators.required), activityType: new FormControl('') }); }Thanks in advance for any help provided!
Posts: 1
Participants: 1