Wednesday, 16 June 2021

radio default slection

 input radio

here is the code for radio button by default selection.

Ts

<h2>{{radioTitle}}</h2>
<label *ngFor="let radiobutton of radioItems">
  <input type="radio" name="options" (click)="model.option = radiobutton"
  [checked]="radiobutton === model.option">{{radiobutton}}
</label>
<p>
  <button (click)="model.option = '12345'">
    Set option #1
  </button>
</p>
<p>
  Selected option: {{model.option}}
</p>





Html
export class AppComponent  {
  radioTitlestring;
  radioItemsArray<string>;
  model   = {option: '12347'};

  constructor() {
    this.radioTitle = 'Radio Button in Angular';
    this.radioItems = ['12345''12346''12347'];
  }
}


No comments:

Post a Comment

7 Common mistakes in Dot Net — You can avoid

  There are many common mistakes made during .NET (ASP.NET, .NET Core) development, which affect performance, security, and code… Code Crack...