我是新的角度,我想改變單選按鈕的顏色是它被選中,也想獲得該值。我嘗試了很多,但得到$範圍未定義。這裏是我的代碼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>
這是我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);
}
})
請幫助我。
謝謝你的建議,但ng模型的價值還沒有得到。 –