Bind Radio Button to numeric values


Topic: Bind Radio Button to numeric values

bitjuice pro asked 6 years ago

Hi,

is it posible to bind Radio Buttons (https://mdbootstrap.com/docs/angular/forms/radio-button/) value to a numeric variable (through [(ngModel)])?

It seems that work only with string variables

<div class="btn-group small-padding-radio w-100">
      <label mdbBtn color="info" rounded="true" [(ngModel)]="artist.artistMainLevelID" mdbRadio="1" mdbWavesEffect>
        Amatore
      </label>
      <label mdbBtn color="info" rounded="true" [(ngModel)]="artist.artistMainLevelID" mdbRadio="2" mdbWavesEffect>
        Semi Pro
      </label>
      <label mdbBtn color="info" rounded="true" [(ngModel)]="artist.artistMainLevelID" mdbRadio="3" mdbWavesEffect>
        Professionista
      </label>
    </div>

  ngOnInit() {
    this.artist.artistMainLevelID = 2;
  }

Thanks

Marco


Damian Gemza staff answered 6 years ago

Dear bitjuice

It seems that the string is the only way to set the radio button value through ngModel.

Best Regards,

Damian


bitjuice pro commented 6 years ago

Thanks for the information Damian


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 7.4.3
  • Device: PC
  • Browser: Chorme
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: Yes