Problem receiving a value from a radio button

1

I'm starting to mess with AngularJS and had a little problem messing with radio buttons . My HTML code:

<!DOCTYPE html>
<html>
<head>
<title>Temperature Converter</title>
<meta charset="UTF-8"/>
</head>
<body ng-app="temp-conv" ng-controller="converter">

<h1>Temperature Converter</h1>
    <h2>Temperatura de entrada</h2>
    <form>
        <input type="text" ng-model="valor"><br>
        <input type="radio" ng-model="ent" value="fahrenheit">Fahrenheit<br>
        <input type="radio" ng-model="ent" value="kelvin">Kelvin<br>
        <input type="radio" ng-model="ent" ng-value="celsius">Celsius<br>
        <input type="radio" ng-model="ent" value="rankine">Rankine<br>
        <input type="radio" ng-model="ent" value="reaumur">Réaumur<br>
        <br>
    <h2>Temperatura de saída</h2>
        <input type="radio" ng-model="sai" value="fahrenheit">Fahrenheit<br>
        <input type="radio" ng-model="sai" value="kelvin">Kelvin<br>
        <input type="radio" ng-model="sai" value="celsius">Celsius<br>
        <input type="radio" ng-model="sai" value="rankine">Rankine<br>
        <input type="radio" ng-model="sai" value="reaumur">Réaumur<br>
        {{ valor }}
    </form>


</body>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script><scriptsrc="script.js"></script>
</html>

And my JavaScript:

var app = angular.module('temp-conv', []);

app.controller('converter', function($scope){
if ($scope.ent === "celsius") {
    $scope.valor = 3;
} else {
    $scope.valor = "4";
}
});

This Js is just a small test to see if the value is being passed, and it is not working.

    
asked by anonymous 24.05.2015 / 03:58

1 answer

0

Check the documentation on how to instantiate the radiobutton angularly to make use of the api.

link

    
24.05.2015 / 04:31