title: Checking PrimeNG-radiobutton by default if only one radio button exists on form
body: <p>I started using PrimeNG components for Angular7 and set up my very first radio buttons. I was able to set specific radio button checked by default. My objective however is to count amount of radio buttons existing on form and set radio button checked by default IF there is only one radio button on form. This is not very ideal approach if values are hard coded but I'm going to add backend for this application later on, so counting amount of radio buttons (rows coming from database) is crucial.</p>
  
  <p>I have searched for solution online and especially Stack but I'm struggling only getting AngularJS or other related solutions. I want to stick with Angular. I'm using Angular7 and PrimeNG UI component.</p>
  
  <p>(PrimeNG documentation: <a href="https://www.primefaces.org/primeng/#/radiobutton" rel="nofollow noreferrer">https://www.primefaces.org/primeng/#/radiobutton</a>)</p>
  
  <p>home.component.html</p>
  
  <pre><code>&lt;h3&gt;Preselected value of "Option 1"&lt;/h3&gt;
  &lt;div class="ui-g" style="width:250px;margin-bottom:10px"&gt;
      &lt;div class="ui-g-12"&gt;&lt;p-radioButton name="group1" value="Option 1" label="Option 1" [(ngModel)]="val1" inputId="preopt1"&gt;&lt;/p-radioButton&gt;&lt;/div&gt;
      &lt;div class="ui-g-12"&gt;&lt;p-radioButton name="group1" value="Option 2" label="Option 2" [(ngModel)]="val1" inputId="preopt2"&gt;&lt;/p-radioButton&gt;&lt;/div&gt;
      &lt;div class="ui-g-12"&gt;&lt;p-radioButton name="group1" value="Option 3" label="Option 3" [(ngModel)]="val1" inputId="preopt3"&gt;&lt;/p-radioButton&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>home.component.ts</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  
  @Component({
    selector: 'app-home',
    templateUrl: './home.component.html',
    styleUrls: ['./home.component.sass']
  })
  export class HomeComponent implements OnInit {
  
    val1: string = 'Option 1';
  
    constructor() { }
  
    ngOnInit() {
    }
  }
  </code></pre>
  
  <p>Expected outcome would be that if only one radio button exists on form, it is selected/checked by default, otherwise don't select/check anything by default.</p>
  
  <p>I'm new to Angular but very eager to learn. Any help would be greatly appreciated. Thank you.</p>