I'm trying to use the example code from this Angularjs example page in my app for input[radio]. I choose to use an object as a value of a particular radio button, so each of the radio buttons in a group has a value of some object.
In the plunkr example, if you set the model to green which is:
$scope.color = {
name: 'green'
};
The proper radio button is not checked by default. I think its because the value of this radio button is an object.
Any ideas how to make it work? How do I check the proper radio button if its value is an object?
You need to reference the model
$scope.color.name
to the "green" object which is defined in thengValue
directive:Because it's
ngValue
directive is bound tospecialValue
Here is a working example.