title: Angular2 how to set radio button as checked with a default value
body: <p>I am new to Angular2, I have a radio group and I am trying to bind it using [(ngModel)] to entity person.testBoolean so that I can save it in the database. I want to set a default value as selected and I have seen few examples and found that they set the default value to [(ngModel)] but in my case I want to bind it to my entity hence I cannot use [(ngModel)]. Can anybody advise alternative options. checked = idx does not work.</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;label for="radioboolean"&gt;Boolean: &lt;/label&gt;
      &lt;div *ngFor="let entry of entries; let idx = index" class="radio-inline" &gt;
         &lt;input type="radio" [(ngModel)]="person.testBoolean" name="radiogroup" [checked]="idx === 1" [value]="entry.id" /&gt;{{ entry.description }}
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Ts code:</p>
  
  <pre><code> entries = [
                {id: 1, description: 'True' },
                {id: 2,description: 'False'},
                {id: 3,description: 'Undefined'}
             ];
  </code></pre>
  
  <p>Person is my entity:</p>
  
  <pre><code>export interface IPerson {
  
      id: string;
      name: string;
      testNumber: number | null;
      testDatetime: Date | null;
      testBoolean: boolean | null;
      // Refs to parent entities
      team: ITeam;
      teamId: string;
  
  };
  </code></pre>