0

I am new on angular, I want to change color of radio button is it selected and also want to get that value. I tried a lot but getting $scope is undefined. Here is my code HTML

<form action="" ng-controller="howSoonContr">
                  <div class="form-group">
                    <div data-toggle="buttons">
                      <label class="btn btn-default btn-circle btn-lg active"><input type="radio" name="q1" value="0" ng-change="howSoonClick()" ng-model="time.min"><a>5 mins</a></label>
                      <label class="btn btn-default btn-circle btn-lg"><input type="radio" name="q2" value="1" ng-model="time.min"><a>10 mins</a></label>
                      <label class="btn btn-default btn-circle btn-lg"><input type="radio" name="q3" value="2" ng-model="time.min"><a>20 mins</a></label>
                       <label class="btn btn-default btn-circle btn-lg"><input type="radio" name="q4" value="3" ng-model="time.min"><a>30 mins</a></label>
                        <label class="btn btn-default btn-circle btn-lg"><input type="radio" name="q5" value="4" ng-model="time.min"><a>45 mins</a></label>
                    </div>
                  </div>
               </form>

This is my js

.controller("howSoonContr", function($scope) {
    console.log("we are in howSoonContr");
    //console.log($scope.time);
    //if ($scope.time) {

        console.log("here is the hello " + $scope.time);

        $scope.howSoonClick = function(time) {
            console.log("here is the hello " + $scope.time);
        }

})

Please help me.

Dylan Wheeler
  • 6,928
  • 14
  • 56
  • 80
Abhay Sharma
  • 221
  • 1
  • 7
  • 24

2 Answers2

0

check this answer : Its using CSS for entire type check box to change color and selection of box

Community
  • 1
  • 1
Vaibhav
  • 1,154
  • 10
  • 26
0

you have to use time.min to access the value, it's not an object it's an array use $scope.time.min

to change color you have to add $watch to it

Vikash Kumar
  • 1,712
  • 1
  • 11
  • 17