Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

[Ionic4] - ion radio group on Reactive Forms

$
0
0

@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 the formControlName on 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

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>