Radio Buttons

">

Radio Buttons

" />
Easy Tutorial
❮ Ionic Ion Slide Box Ionic Gesture Event ❯

Ionic Radio Button Operations

In the example, different values are displayed based on the selected option.

HTML Code

<ion-header-bar class="bar-positive">
  <h1 class="title">Radio Buttons</h1>
</ion-header-bar>

<ion-content>

  <div class="list">

    <div class="item item-divider"> 
      Selected Value: {{ data.clientSide }}
    </div>

    &lt;ion-radio ng-repeat="item in clientSideList"
               ng-value="item.value"
               ng-model="data.clientSide">
      {{ item.text }}
    </ion-radio>

    <div class="item item-divider">
      Serverside, Selected Value: {{ data.serverSide }}
    </div>

    &lt;ion-radio ng-repeat="item in serverSideList"
               ng-value="item.value"
               ng-model="data.serverSide"
               ng-change="serverSideChange(item)"
               name="server-side">
      {{ item.text }}
    </ion-radio>

  </div>

</ion-content>

JavaScript Code

angular.module('ionicApp', ['ionic'])

.controller('MainCtrl', function($scope) {

  $scope.clientSideList = [
    { text: "Backbone", value: "bb" },
    { text: "Angular", value: "ng" },
    { text: "Ember", value: "em" },
    { text: "Knockout", value: "ko" }
  ];

  $scope.serverSideList = [
    { text: "Go", value: "go" },
    { text: "Python", value: "py" },
    { text: "Ruby", value: "rb" },
    { text: "Java", value: "jv" }
  ];

  $scope.data = {
    clientSide: 'ng'
  };

  $scope.serverSideChange = function(item) {
    console.log("Selected Serverside, text:", item.text, "value:", item.value);
  };

});

CSS Code:

body {
  cursor: url('http://www.tutorialpro.org/try/demo_source/finger.png'), auto;
}

Try it »

The result is as follows:

❮ Ionic Ion Slide Box Ionic Gesture Event ❯