0
<ion-list>
<ion-radio ng-model="choice" ng-value="'A'" ng-click='usedGNG("yes")'>Yes</ion-radio>
<ion-radio ng-model="choice" ng-value="'B'" ng-click='usedGNG("no")'>No</ion-radio>
</ion-list>

These are the two radio buttons i've created... And now i want to select one of this radio button using angular js script...I've googled it but didn't find the solution or i may not understood it correctly...So please somebody help me out..Thanks for the Help...

1

1 Answer 1

3

Just update the model of the radio buttons either inside the directive or from the controller.

JS CODE:

angular.module('ionicApp', ['ionic'])
   .controller('HomeCtrl', function($scope) {
      $scope.choice = 'Ember';
});

HTML CODE:

<div ng-app="ionicApp" ng-controller="HomeCtrl">
  <ion-list>
    <ion-radio ng-model="choice" ng-value="'Angular'">Angular</ion-radio>
    <ion-radio ng-model="choice" ng-value="'Ember'">Ember</ion-radio>
  </ion-list>
  <button class="button button-dark" ng-click="choice ='Angular'">
     Set Angular
  </button>
</div>

Live Demo @ JSFiddle

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you dude...I've seen the examples in google...but you are very clear and specific...thanks for your help...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.