Hi everybody,
I try to bind the value-attr of an radio to a model-value, but radios
won't get checked correctly.
Below is an example.
I found the radioAccessor - function in angular.js. I think that
function is ment to ensure the radios to be checked correctly:
set: function(value){
domElement.checked = value == domElement.value;
}
Unfortunatly, with a radio: <input type="radio"
name="form_1.selectedValue" value="{{form_1.val_a}}" />
domElement.value == "on" (what does this mean?)
does hold instead of
domElement.value == "a"
Afterwards the radios work correctly.
Could somebody explain this to me...?
Maybe the value-attrs of <input/>-Tags are not meant to be bound to
model values?
But wouldn't that be nice, especially if this is only an init/eval-
order issue...?
(btw. ng:eval-order="LAST" does not help)
Best regards,
Max
<html>
<head>
<script type="text/javascript" src="
http://angularjs.org/ng/js/
angular-debug.js" ng:autobind></script>
</script>
<script>
function Ctrl ()
{
this.master_1 =
{
val_a: "a",
val_b: "b",
selectedValue: "a"
}
this.master_2 =
{
selectedValue: "a"
}
this.form_1 = angular.copy( this.master_1 );
this.form_2 = angular.copy( this.master_2 );
}
</script>
</head>
<body xmlns:ng="
http://angularjs.org" >
<div ng:controller="Ctrl">
<pre>form_1: {{form_1|json}}</pre>
<!-- does not work -->
<input type="radio" name="form_1.selectedValue"
value="{{form_1.val_a}}" />{{form_1.val_a}}
<input type="radio" name="form_1.selectedValue"
value="{{form_1.val_b}}" />{{form_1.val_b}}
<hr />
<pre>form_2: {{form_2|json}}</pre>
<!-- works -->
<input type="radio" name="form_2.selectedValue" value="a" />a
<input type="radio" name="form_2.selectedValue" value="b" />b
</div>
</body>
</html>