Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

Problem Detecting Radio Button Change Event in Ionic 2

$
0
0

What is the proper way to detect a change on a radio button in Ionic 2? The template looks like this:

  <ion-list radio-group (change)="saveSettings();" [(ngModel)]="units">

    <ion-item>
      <ion-label>Imperial (lbs)</ion-label>
      <ion-radio value="lbs"></ion-radio>
    </ion-item>

    <ion-item>
      <ion-label>Metric (kg)</ion-label>
      <ion-radio value="kg"></ion-radio>
    </ion-item>

  </ion-list>

The issue is the change event is emitted before the units variable is updated, which causes the previous value to be re-saved in the database, not the new radio selection.


Viewing all articles
Browse latest Browse all 228595

Trending Articles



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