I've been trying to figure this out for a couple of days now...
I've got a set of radio buttons to rate something between 1 and 5 with each set to value = 1, value = 2 and so on as part of a comment form. But when the data is returned to the controller and is pushed to the db.json file, the radio button values are of type string. How do I get them to be of type int?
Radio button HTML code:
<label class = "radio-inline" for = "one"><input type = "radio"
name = "rating" id = "one" data-ng-model = "userComment.rating"
value = 1 required>1</label>
code from controllers.js:
$scope.submitComment = function() {
$scope.movie.comments.push($scope.userComment);
myFactory.getMovies().update({id:$scope.movie.id}, $scope.movie);
I tried this thinking it would work, but it didn't.
$scope.userComment.rating = parseInt($scope.userComment.rating);
parseInt($scope.userComment.rating);this should work as expected, where it is showing as string. justconsole.log($scope.userComment.rating)afterpasrseInt.console.log()it.