0

i have a problem sending a radio button value to my controller here is my html :

<input class="i-radio" name="_rate"  ng-model="rate"  ng-value="'-100'" type="radio" />-5 star (-100)</label>

<button class="btn btn-primary col-sm-offset-4" type="submit" ng-click="evaluation(rate)">Evaluez</button>

my controller :

 $scope.evaluation = function(rate){
    console.log(rate);
}

my problem is the rate.value is always undefined

5
  • What is the error ? Also you should try to provide a fiddle demonstrating the issue if possible. Commented Apr 10, 2016 at 11:20
  • my problem is when ever i click on my submit button the rate value is always undefined Commented Apr 10, 2016 at 11:23
  • do check it then submit? Commented Apr 10, 2016 at 11:30
  • ofc i checked it and then submited Commented Apr 10, 2016 at 11:34
  • try making a demo of your problem code in jsfiddle, that will help to better understand where the problem is. Commented Apr 10, 2016 at 11:56

2 Answers 2

1

i figure it out my mistake was in my html the class i-radio was somehow blocking the check of the radio button

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

Comments

0

It's all alright, just you didn't specified any controller I think, try this code that I write for you:

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<script>
var app = angular.module("angApp", []);
app.controller("angCtrl", function($scope) {
 $scope.evaluation = function(rate){
    console.log(rate);
}
});

</script>
<div ng-app="angApp" ng-controller="angCtrl">

<input class="i-radio" name="_rate"  ng-model="rate"  ng-value="'-100'" type="radio" />-5 star (-100)</label>

<button class="btn btn-primary col-sm-offset-4" type="submit" ng-click="evaluation(rate)">Evaluez</button>

</div>

</body>
</html>

Hope helped you ---

1 Comment

thank you #Alireza but the problem was in my html i was using the iCheck plugin and it was not working with my angular directive now evrything works fine :)

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.